mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-08 06:04:56 +03:00
chore: ran prettier
This commit is contained in:
parent
3c3d5326bb
commit
4bb9b14eda
|
@ -195,6 +195,7 @@
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"trailingComma": "all",
|
"trailingComma": "all",
|
||||||
"printWidth": 100,
|
"printWidth": 100,
|
||||||
"parser": "typescript"
|
"parser": "typescript",
|
||||||
|
"arrowParens": "avoid"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ const headerFontSize = {
|
||||||
3: '1.27em',
|
3: '1.27em',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const headerCommonMixin = (level) => css`
|
export const headerCommonMixin = level => css`
|
||||||
font-family: ${({ theme }) => theme.typography.headings.fontFamily};
|
font-family: ${({ theme }) => theme.typography.headings.fontFamily};
|
||||||
font-weight: ${({ theme }) => theme.typography.headings.fontWeight};
|
font-weight: ${({ theme }) => theme.typography.headings.fontWeight};
|
||||||
font-size: ${headerFontSize[level]};
|
font-size: ${headerFontSize[level]};
|
||||||
|
|
|
@ -31,7 +31,7 @@ export const Tabs = styled(ReactTabs)`
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
||||||
&.react-tabs__tab--selected {
|
&.react-tabs__tab--selected {
|
||||||
color: ${(props) => props.theme.rightPanel.tabs.selectedTextColor};
|
color: ${props => props.theme.rightPanel.tabs.selectedTextColor};
|
||||||
background: ${({ theme }) => theme.rightPanel.tabs.selectedBackgroundColor};
|
background: ${({ theme }) => theme.rightPanel.tabs.selectedBackgroundColor};
|
||||||
&:focus {
|
&:focus {
|
||||||
outline: auto;
|
outline: auto;
|
||||||
|
@ -44,19 +44,19 @@ export const Tabs = styled(ReactTabs)`
|
||||||
}
|
}
|
||||||
|
|
||||||
&.tab-success {
|
&.tab-success {
|
||||||
color: ${(props) => props.theme.colors.responses.success.color};
|
color: ${props => props.theme.colors.responses.success.color};
|
||||||
}
|
}
|
||||||
|
|
||||||
&.tab-redirect {
|
&.tab-redirect {
|
||||||
color: ${(props) => props.theme.colors.responses.redirect.color};
|
color: ${props => props.theme.colors.responses.redirect.color};
|
||||||
}
|
}
|
||||||
|
|
||||||
&.tab-info {
|
&.tab-info {
|
||||||
color: ${(props) => props.theme.colors.responses.info.color};
|
color: ${props => props.theme.colors.responses.info.color};
|
||||||
}
|
}
|
||||||
|
|
||||||
&.tab-error {
|
&.tab-error {
|
||||||
color: ${(props) => props.theme.colors.responses.error.color};
|
color: ${props => props.theme.colors.responses.error.color};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ export const Tabs = styled(ReactTabs)`
|
||||||
background: ${({ theme }) => theme.codeBlock.backgroundColor};
|
background: ${({ theme }) => theme.codeBlock.backgroundColor};
|
||||||
& > div,
|
& > div,
|
||||||
& > pre {
|
& > pre {
|
||||||
padding: ${(props) => props.theme.spacing.unit * 4}px;
|
padding: ${props => props.theme.spacing.unit * 4}px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ export const SmallTabs = styled(Tabs)`
|
||||||
> .react-tabs__tab-panel {
|
> .react-tabs__tab-panel {
|
||||||
& > div,
|
& > div,
|
||||||
& > pre {
|
& > pre {
|
||||||
padding: ${(props) => props.theme.spacing.unit * 2}px 0;
|
padding: ${props => props.theme.spacing.unit * 2}px 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -7,7 +7,7 @@ export const OperationEndpointWrap = styled.div`
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const ServerRelativeURL = styled.span`
|
export const ServerRelativeURL = styled.span`
|
||||||
font-family: ${(props) => props.theme.typography.code.fontFamily};
|
font-family: ${props => props.theme.typography.code.fontFamily};
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
@ -20,22 +20,22 @@ export const EndpointInfo = styled.button<{ expanded?: boolean; inverted?: boole
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 10px 30px 10px ${(props) => (props.inverted ? '10px' : '20px')};
|
padding: 10px 30px 10px ${props => (props.inverted ? '10px' : '20px')};
|
||||||
border-radius: ${(props) => (props.inverted ? '0' : '4px 4px 0 0')};
|
border-radius: ${props => (props.inverted ? '0' : '4px 4px 0 0')};
|
||||||
background-color: ${(props) =>
|
background-color: ${props =>
|
||||||
props.inverted ? 'transparent' : props.theme.codeBlock.backgroundColor};
|
props.inverted ? 'transparent' : props.theme.codeBlock.backgroundColor};
|
||||||
display: flex;
|
display: flex;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border: ${(props) => (props.inverted ? '0' : '1px solid transparent')};
|
border: ${props => (props.inverted ? '0' : '1px solid transparent')};
|
||||||
border-bottom: ${(props) => (props.inverted ? '1px solid #ccc' : '0')};
|
border-bottom: ${props => (props.inverted ? '1px solid #ccc' : '0')};
|
||||||
transition: border-color 0.25s ease;
|
transition: border-color 0.25s ease;
|
||||||
|
|
||||||
${(props) =>
|
${props =>
|
||||||
(props.expanded && !props.inverted && `border-color: ${props.theme.colors.border.dark};`) || ''}
|
(props.expanded && !props.inverted && `border-color: ${props.theme.colors.border.dark};`) || ''}
|
||||||
|
|
||||||
.${ServerRelativeURL} {
|
.${ServerRelativeURL} {
|
||||||
color: ${(props) => (props.inverted ? props.theme.colors.text.primary : '#ffffff')}
|
color: ${props => (props.inverted ? props.theme.colors.text.primary : '#ffffff')}
|
||||||
}
|
}
|
||||||
&:focus {
|
&:focus {
|
||||||
box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.45), 0 2px 0 rgba(128, 128, 128, 0.25);
|
box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.45), 0 2px 0 rgba(128, 128, 128, 0.25);
|
||||||
|
@ -45,13 +45,13 @@ export const EndpointInfo = styled.button<{ expanded?: boolean; inverted?: boole
|
||||||
export const HttpVerb = styled.span.attrs((props: { type: string; compact?: boolean }) => ({
|
export const HttpVerb = styled.span.attrs((props: { type: string; compact?: boolean }) => ({
|
||||||
className: `http-verb ${props.type}`,
|
className: `http-verb ${props.type}`,
|
||||||
}))<{ type: string; compact?: boolean }>`
|
}))<{ type: string; compact?: boolean }>`
|
||||||
font-size: ${(props) => (props.compact ? '0.8em' : '0.929em')};
|
font-size: ${props => (props.compact ? '0.8em' : '0.929em')};
|
||||||
line-height: ${(props) => (props.compact ? '18px' : '20px')};
|
line-height: ${props => (props.compact ? '18px' : '20px')};
|
||||||
background-color: ${(props) => props.theme.colors.http[props.type] || '#999999'};
|
background-color: ${props => props.theme.colors.http[props.type] || '#999999'};
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
padding: ${(props) => (props.compact ? '2px 8px' : '3px 10px')};
|
padding: ${props => (props.compact ? '2px 8px' : '3px 10px')};
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-family: ${(props) => props.theme.typography.headings.fontFamily};
|
font-family: ${props => props.theme.typography.headings.fontFamily};
|
||||||
margin: 0;
|
margin: 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ export const ServersOverlay = styled.div<{ expanded: boolean }>`
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
background: ${(props) => props.theme.rightPanel.endpoint.backgroundColor};
|
background: ${props => props.theme.rightPanel.endpoint.backgroundColor};
|
||||||
color: ${(props) => props.theme.rightPanel.endpoint.textColor};
|
color: ${props => props.theme.rightPanel.endpoint.textColor};
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.33);
|
box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.33);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -68,7 +68,7 @@ export const ServersOverlay = styled.div<{ expanded: boolean }>`
|
||||||
border-bottom-right-radius: 4px;
|
border-bottom-right-radius: 4px;
|
||||||
transition: all 0.25s ease;
|
transition: all 0.25s ease;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
${(props) => (props.expanded ? 'visibility: visible;' : 'transform: translateY(-50%) scaleY(0);')}
|
${props => (props.expanded ? 'visibility: visible;' : 'transform: translateY(-50%) scaleY(0);')}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const ServerItem = styled.div`
|
export const ServerItem = styled.div`
|
||||||
|
@ -78,10 +78,10 @@ export const ServerItem = styled.div`
|
||||||
export const ServerUrl = styled.div`
|
export const ServerUrl = styled.div`
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
background: ${(props) => props.theme.rightPanel.endpoint.serverBackgroundColor};
|
background: ${props => props.theme.rightPanel.endpoint.serverBackgroundColor};
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
color: ${(props) => props.theme.rightPanel.endpoint.serverTextColor};
|
color: ${props => props.theme.rightPanel.endpoint.serverTextColor};
|
||||||
> span {
|
> span {
|
||||||
color: ${(props) => props.theme.rightPanel.endpoint.serverTextColor};
|
color: ${props => props.theme.rightPanel.endpoint.serverTextColor};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Schema, SchemaProps } from './Schema';
|
||||||
|
|
||||||
import { ArrayClosingLabel, ArrayOpenningLabel } from '../../common-elements';
|
import { ArrayClosingLabel, ArrayOpenningLabel } from '../../common-elements';
|
||||||
import styled from '../../styled-components';
|
import styled from '../../styled-components';
|
||||||
import {humanizeConstraints} from "../../utils";
|
import { humanizeConstraints } from '../../utils';
|
||||||
|
|
||||||
const PaddedSchema = styled.div`
|
const PaddedSchema = styled.div`
|
||||||
padding-left: ${({ theme }) => theme.spacing.unit * 2}px;
|
padding-left: ${({ theme }) => theme.spacing.unit * 2}px;
|
||||||
|
@ -18,7 +18,9 @@ export class ArraySchema extends React.PureComponent<SchemaProps> {
|
||||||
max: number | undefined = undefined,
|
max: number | undefined = undefined,
|
||||||
) => ({ type: 'array', minItems: min, maxItems: max });
|
) => ({ type: 'array', minItems: min, maxItems: max });
|
||||||
|
|
||||||
const minMaxItems = humanizeConstraints(itemConstraintSchema(itemsSchema.schema.minItems, itemsSchema.schema.maxItems));
|
const minMaxItems = humanizeConstraints(
|
||||||
|
itemConstraintSchema(itemsSchema.schema.minItems, itemsSchema.schema.maxItems),
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -121,10 +121,7 @@ export class MarkdownRenderer {
|
||||||
prevRegexp = regexp;
|
prevRegexp = regexp;
|
||||||
prevPos = currentPos;
|
prevPos = currentPos;
|
||||||
}
|
}
|
||||||
prevHeading.description = rawText
|
prevHeading.description = rawText.substring(prevPos).replace(prevRegexp, '').trim();
|
||||||
.substring(prevPos)
|
|
||||||
.replace(prevRegexp, '')
|
|
||||||
.trim();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
headingRule = (
|
headingRule = (
|
||||||
|
|
|
@ -68,7 +68,7 @@ export class RedocNormalizedOptions {
|
||||||
}
|
}
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
const res = {};
|
const res = {};
|
||||||
value.split(',').forEach((code) => {
|
value.split(',').forEach(code => {
|
||||||
res[code.trim()] = true;
|
res[code.trim()] = true;
|
||||||
});
|
});
|
||||||
return res;
|
return res;
|
||||||
|
@ -134,7 +134,7 @@ export class RedocNormalizedOptions {
|
||||||
case 'false':
|
case 'false':
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return value.split(',').map((ext) => ext.trim());
|
return value.split(',').map(ext => ext.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ export class OperationModel implements IMenuItem {
|
||||||
// NOTE: Callbacks by default should not inherit the specification's global `security` definition.
|
// NOTE: Callbacks by default should not inherit the specification's global `security` definition.
|
||||||
// Can be defined individually per-callback in the specification. Defaults to none.
|
// Can be defined individually per-callback in the specification. Defaults to none.
|
||||||
this.security = (operationSpec.security || []).map(
|
this.security = (operationSpec.security || []).map(
|
||||||
(security) => new SecurityRequirementModel(security, parser),
|
security => new SecurityRequirementModel(security, parser),
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: update getting pathInfo for overriding servers on path level
|
// TODO: update getting pathInfo for overriding servers on path level
|
||||||
|
@ -116,7 +116,7 @@ export class OperationModel implements IMenuItem {
|
||||||
: this.pointer;
|
: this.pointer;
|
||||||
|
|
||||||
this.security = (operationSpec.security || parser.spec.security || []).map(
|
this.security = (operationSpec.security || parser.spec.security || []).map(
|
||||||
(security) => new SecurityRequirementModel(security, parser),
|
security => new SecurityRequirementModel(security, parser),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.servers = normalizeServers(
|
this.servers = normalizeServers(
|
||||||
|
@ -208,7 +208,7 @@ export class OperationModel implements IMenuItem {
|
||||||
this.operationSpec.pathParameters,
|
this.operationSpec.pathParameters,
|
||||||
this.operationSpec.parameters,
|
this.operationSpec.parameters,
|
||||||
// TODO: fix pointer
|
// TODO: fix pointer
|
||||||
).map((paramOrRef) => new FieldModel(this.parser, paramOrRef, this.pointer, this.options));
|
).map(paramOrRef => new FieldModel(this.parser, paramOrRef, this.pointer, this.options));
|
||||||
|
|
||||||
if (this.options.sortPropsAlphabetically) {
|
if (this.options.sortPropsAlphabetically) {
|
||||||
return sortByField(_parameters, 'name');
|
return sortByField(_parameters, 'name');
|
||||||
|
@ -224,7 +224,7 @@ export class OperationModel implements IMenuItem {
|
||||||
get responses() {
|
get responses() {
|
||||||
let hasSuccessResponses = false;
|
let hasSuccessResponses = false;
|
||||||
return Object.keys(this.operationSpec.responses || [])
|
return Object.keys(this.operationSpec.responses || [])
|
||||||
.filter((code) => {
|
.filter(code => {
|
||||||
if (code === 'default') {
|
if (code === 'default') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ export class OperationModel implements IMenuItem {
|
||||||
|
|
||||||
return isStatusCode(code);
|
return isStatusCode(code);
|
||||||
}) // filter out other props (e.g. x-props)
|
}) // filter out other props (e.g. x-props)
|
||||||
.map((code) => {
|
.map(code => {
|
||||||
return new ResponseModel(
|
return new ResponseModel(
|
||||||
this.parser,
|
this.parser,
|
||||||
code,
|
code,
|
||||||
|
@ -248,7 +248,7 @@ export class OperationModel implements IMenuItem {
|
||||||
|
|
||||||
@memoize
|
@memoize
|
||||||
get callbacks() {
|
get callbacks() {
|
||||||
return Object.keys(this.operationSpec.callbacks || []).map((callbackEventName) => {
|
return Object.keys(this.operationSpec.callbacks || []).map(callbackEventName => {
|
||||||
return new CallbackModel(
|
return new CallbackModel(
|
||||||
this.parser,
|
this.parser,
|
||||||
callbackEventName,
|
callbackEventName,
|
||||||
|
|
24
src/theme.ts
24
src/theme.ts
|
@ -80,21 +80,21 @@ const defaultTheme: ThemeInterface = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
schema: {
|
schema: {
|
||||||
linesColor: (theme) =>
|
linesColor: theme =>
|
||||||
lighten(
|
lighten(
|
||||||
theme.colors.tonalOffset,
|
theme.colors.tonalOffset,
|
||||||
desaturate(theme.colors.tonalOffset, theme.colors.primary.main),
|
desaturate(theme.colors.tonalOffset, theme.colors.primary.main),
|
||||||
),
|
),
|
||||||
defaultDetailsWidth: '75%',
|
defaultDetailsWidth: '75%',
|
||||||
typeNameColor: (theme) => theme.colors.text.secondary,
|
typeNameColor: theme => theme.colors.text.secondary,
|
||||||
typeTitleColor: (theme) => theme.schema.typeNameColor,
|
typeTitleColor: theme => theme.schema.typeNameColor,
|
||||||
requireLabelColor: (theme) => theme.colors.error.main,
|
requireLabelColor: theme => theme.colors.error.main,
|
||||||
labelsTextSize: '0.9em',
|
labelsTextSize: '0.9em',
|
||||||
nestingSpacing: '1em',
|
nestingSpacing: '1em',
|
||||||
nestedBackground: '#fafafa',
|
nestedBackground: '#fafafa',
|
||||||
arrow: {
|
arrow: {
|
||||||
size: '1.1em',
|
size: '1.1em',
|
||||||
color: (theme) => theme.colors.text.secondary,
|
color: theme => theme.colors.text.secondary,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
typography: {
|
typography: {
|
||||||
|
@ -130,7 +130,7 @@ const defaultTheme: ThemeInterface = {
|
||||||
width: '260px',
|
width: '260px',
|
||||||
backgroundColor: '#fafafa',
|
backgroundColor: '#fafafa',
|
||||||
textColor: '#333333',
|
textColor: '#333333',
|
||||||
activeTextColor: (theme) =>
|
activeTextColor: theme =>
|
||||||
theme.sidebar.textColor !== defaultTheme.sidebar!.textColor
|
theme.sidebar.textColor !== defaultTheme.sidebar!.textColor
|
||||||
? theme.sidebar.textColor
|
? theme.sidebar.textColor
|
||||||
: theme.colors.primary.main,
|
: theme.colors.primary.main,
|
||||||
|
@ -142,7 +142,7 @@ const defaultTheme: ThemeInterface = {
|
||||||
},
|
},
|
||||||
arrow: {
|
arrow: {
|
||||||
size: '1.5em',
|
size: '1.5em',
|
||||||
color: (theme) => theme.sidebar.textColor,
|
color: theme => theme.sidebar.textColor,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
logo: {
|
logo: {
|
||||||
|
@ -155,14 +155,14 @@ const defaultTheme: ThemeInterface = {
|
||||||
width: '40%',
|
width: '40%',
|
||||||
textColor: '#ffffff',
|
textColor: '#ffffff',
|
||||||
tabs: {
|
tabs: {
|
||||||
selectedBackgroundColor: (theme) => theme.rightPanel.textColor,
|
selectedBackgroundColor: theme => theme.rightPanel.textColor,
|
||||||
selectedTextColor: (theme) => theme.colors.text.primary,
|
selectedTextColor: theme => theme.colors.text.primary,
|
||||||
},
|
},
|
||||||
endpoint: {
|
endpoint: {
|
||||||
backgroundColor: '#fafafa',
|
backgroundColor: '#fafafa',
|
||||||
textColor: (theme) => theme.colors.primary.main,
|
textColor: theme => theme.colors.primary.main,
|
||||||
serverBackgroundColor: '#ffffff',
|
serverBackgroundColor: '#ffffff',
|
||||||
serverTextColor: (theme) => theme.colors.text.primary,
|
serverTextColor: theme => theme.colors.text.primary,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
codeBlock: {
|
codeBlock: {
|
||||||
|
@ -176,7 +176,7 @@ export function resolveTheme(theme: ThemeInterface): ResolvedThemeInterface {
|
||||||
const resolvedValues = {};
|
const resolvedValues = {};
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
const setProxy = (obj, path: string) => {
|
const setProxy = (obj, path: string) => {
|
||||||
Object.keys(obj).forEach((k) => {
|
Object.keys(obj).forEach(k => {
|
||||||
const currentPath = (path ? path + '.' : '') + k;
|
const currentPath = (path ? path + '.' : '') + k;
|
||||||
const val = obj[k];
|
const val = obj[k];
|
||||||
if (typeof val === 'function') {
|
if (typeof val === 'function') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user