From c6eaa0281bb0f62b019c865e4aefb863ce84d628 Mon Sep 17 00:00:00 2001 From: GreenHedgehog Date: Fri, 20 Mar 2020 15:37:22 +0300 Subject: [PATCH 1/8] fix: fix passing boolean value to showExtensions options (#1211) Co-authored-by: Alef --- src/services/RedocNormalizedOptions.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/services/RedocNormalizedOptions.ts b/src/services/RedocNormalizedOptions.ts index 282f4eb1..219ad286 100644 --- a/src/services/RedocNormalizedOptions.ts +++ b/src/services/RedocNormalizedOptions.ts @@ -112,11 +112,18 @@ export class RedocNormalizedOptions { return true; } - if (typeof value === 'string') { - return value.split(',').map(ext => ext.trim()); + if (typeof value !== 'string') { + return value } - return value; + switch (value) { + case 'true': + return true + case 'false': + return false + default: + return value.split(',').map(ext => ext.trim()); + } } static normalizePayloadSampleIdx(value: RedocRawOptions['payloadSampleIdx']): number { From 830371b5d1edf4ba7a138b3b3d78148d020e0349 Mon Sep 17 00:00:00 2001 From: Oleksiy Kachynskyy Date: Fri, 20 Mar 2020 15:05:07 +0200 Subject: [PATCH 2/8] fix: do not collapse top level on Collapse All in json samples (#1209) * fix: update collapseAll method to avoid collapsing whole object/array * fix: remove extra "slice()" call --- src/components/JsonViewer/JsonViewer.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/JsonViewer/JsonViewer.tsx b/src/components/JsonViewer/JsonViewer.tsx index bf735299..d42c9df7 100644 --- a/src/components/JsonViewer/JsonViewer.tsx +++ b/src/components/JsonViewer/JsonViewer.tsx @@ -57,11 +57,10 @@ class Json extends React.PureComponent { collapseAll = () => { const elements = this.node.getElementsByClassName('collapsible'); - for (const expanded of Array.prototype.slice.call(elements)) { - // const collapsed = elements[i]; - if ((expanded.parentNode as Element)!.classList.contains('redoc-json')) { - continue; - } + // skip first item to avoid collapsing whole object/array + const elementsArr = Array.prototype.slice.call(elements, 1); + + for (const expanded of elementsArr) { (expanded.parentNode as Element)!.classList.add('collapsed'); } }; From ea5b0aabf9133d11d3a8fcb79f9515d21e0d7ac0 Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Fri, 27 Mar 2020 11:09:44 +0100 Subject: [PATCH 3/8] feat: add x-explicitMappingOnly extension (#1215) --- docs/redoc-vendor-extensions.md | 34 +++++++++++++++++++++++++++++++++ src/services/models/Schema.ts | 11 ++++++++++- src/types/open-api.d.ts | 1 + src/utils/openapi.ts | 1 + 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/docs/redoc-vendor-extensions.md b/docs/redoc-vendor-extensions.md index f02bc9b2..e69affed 100644 --- a/docs/redoc-vendor-extensions.md +++ b/docs/redoc-vendor-extensions.md @@ -306,3 +306,37 @@ Player: x-additionalPropertiesName: attribute-name type: string ``` + +#### x-explicitMappingOnly +**ATTENTION**: This is ReDoc-specific vendor extension. It won't be supported by other tools. + +Extends the `discriminator` property of the schema object. + +| Field Name | Type | Description | +| :------------- | :------: | :---------- | +| x-explicitMappingOnly | boolean | limit the discriminator selectpicker to the explicit mappings only | + +###### Usage in ReDoc +ReDoc uses this extension to filter the `discriminator` mappings shown in the selectpicker. +When set to `true`, the selectpicker will only list the the explicitly defined mappings. When `false`, +the default behavior is kept, i.e. explicit and implicit mappings will be shown. + +###### x-explicitMappingOnly example + + +```yaml +Pet: + type: object + required: + - name + - photoUrls + discriminator: + propertyName: petType + x-explicitMappingOnly: true + mapping: + cat: "#/components/schemas/Cat" + bee: "#/components/schemas/HoneyBee" +``` + +Will show in the selectpicker only the items `cat` and `bee`, even though the `Dog` class inherits from +the `Pet` class. diff --git a/src/services/models/Schema.ts b/src/services/models/Schema.ts index 7fb5a8e9..b6401c9a 100644 --- a/src/services/models/Schema.ts +++ b/src/services/models/Schema.ts @@ -240,6 +240,15 @@ export class SchemaModel { } const mapping = discriminator.mapping || {}; + + // Defines if the mapping is exhaustive. This avoids having references + // that overlap with the mapping entries + let isLimitedToMapping = discriminator['x-explicitMappingOnly'] || false; + // if there are no mappings, assume non-exhaustive + if (Object.keys(mapping).length === 0) { + isLimitedToMapping = false; + } + const explicitInversedMapping = {}; for (const name in mapping) { const $ref = mapping[name]; @@ -252,7 +261,7 @@ export class SchemaModel { } } - const inversedMapping = { ...implicitInversedMapping, ...explicitInversedMapping }; + const inversedMapping = isLimitedToMapping ? { ...explicitInversedMapping } : { ...implicitInversedMapping, ...explicitInversedMapping }; const refs: Array<{ $ref; name }> = []; diff --git a/src/types/open-api.d.ts b/src/types/open-api.d.ts index 4fb04a83..891d7a0f 100644 --- a/src/types/open-api.d.ts +++ b/src/types/open-api.d.ts @@ -144,6 +144,7 @@ export interface OpenAPISchema { export interface OpenAPIDiscriminator { propertyName: string; mapping?: { [name: string]: string }; + 'x-explicitMappingOnly'?: boolean; } export interface OpenAPIMediaType { diff --git a/src/utils/openapi.ts b/src/utils/openapi.ts index 74511e3d..1ee0bd14 100644 --- a/src/utils/openapi.ts +++ b/src/utils/openapi.ts @@ -579,6 +579,7 @@ export function isRedocExtension(key: string): boolean { 'x-tagGroups': true, 'x-traitTag': true, 'x-additionalPropertiesName': true, + 'x-explicitMappingOnly': true, }; return key in redocExtensions; From ac4f915494f289d1c97ffdfe3af59efd94734f8c Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Fri, 27 Mar 2020 12:09:51 +0100 Subject: [PATCH 4/8] fix: sort discriminator entries by mapping order (#1216) * sort discriminator entries by mapping order * fix string compare --- src/services/models/Schema.ts | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/services/models/Schema.ts b/src/services/models/Schema.ts index b6401c9a..722c2bb7 100644 --- a/src/services/models/Schema.ts +++ b/src/services/models/Schema.ts @@ -263,7 +263,7 @@ export class SchemaModel { const inversedMapping = isLimitedToMapping ? { ...explicitInversedMapping } : { ...implicitInversedMapping, ...explicitInversedMapping }; - const refs: Array<{ $ref; name }> = []; + let refs: Array<{ $ref; name }> = []; for (const $ref of Object.keys(inversedMapping)) { const names = inversedMapping[$ref]; @@ -276,6 +276,35 @@ export class SchemaModel { } } + // Make the listing respects the mapping + // in case a mapping is defined, the user usually wants to have the order shown + // as it was defined in the yaml. This will sort the names given the provided + // mapping (if provided). + // The logic is: + // - If a name is among the mapping, promote it to first + // - Names among the mapping are sorted by their order in the mapping + // - Names outside the mapping are sorted alphabetically + const names = Object.keys(mapping); + if (names.length !== 0) { + refs = refs.sort((left, right) => { + const indexLeft = names.indexOf(left.name); + const indexRight = names.indexOf(right.name); + + if (indexLeft < 0 && indexRight < 0) { + // out of mapping, order by name + return left.name.localCompare(right.name); + } else if (indexLeft < 0) { + // the right is found, so mapping wins + return 1; + } else if (indexRight < 0) { + // left wins as it's in mapping + return -1; + } else { + return indexLeft - indexRight; + } + }); + } + this.oneOf = refs.map(({ $ref, name }) => { const innerSchema = new SchemaModel(parser, parser.byRef($ref)!, $ref, this.options, true); innerSchema.title = name; From a0bd27c75427a39abc9c753b0654678eed2f3851 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 27 Mar 2020 16:31:53 +0200 Subject: [PATCH 5/8] fix: improve names for some theme settings --- src/common-elements/tabs.ts | 6 ++-- src/components/Endpoint/styled.elements.ts | 2 +- src/components/Markdown/styled.elements.tsx | 2 +- src/components/Redoc/styled.elements.tsx | 4 +-- .../SchemaDefinition/SchemaDefinition.tsx | 2 +- src/components/SearchBox/styled.elements.tsx | 18 +++++------ src/components/SideMenu/styled.elements.ts | 31 ++++++++++--------- .../StickySidebar/StickyResponsiveSidebar.tsx | 6 ++-- src/services/RedocNormalizedOptions.ts | 18 +++++++++-- src/theme.ts | 26 ++++++++-------- 10 files changed, 64 insertions(+), 51 deletions(-) diff --git a/src/common-elements/tabs.ts b/src/common-elements/tabs.ts index b1ad066a..5063d64b 100644 --- a/src/common-elements/tabs.ts +++ b/src/common-elements/tabs.ts @@ -16,7 +16,7 @@ export const Tabs = styled(ReactTabs)` padding: 5px 10px; display: inline-block; - background-color: ${({ theme }) => theme.codeSample.backgroundColor}; + background-color: ${({ theme }) => theme.codeBlock.backgroundColor}; border-bottom: 1px solid rgba(0, 0, 0, 0.5); cursor: pointer; text-align: center; @@ -24,7 +24,7 @@ export const Tabs = styled(ReactTabs)` color: ${({ theme }) => darken(theme.colors.tonalOffset, theme.rightPanel.textColor)}; margin: 0 ${({ theme }) => `${theme.spacing.unit}px ${theme.spacing.unit}px ${theme.spacing.unit}px`}; - border: 1px solid ${({ theme }) => darken(0.05, theme.codeSample.backgroundColor)}; + border: 1px solid ${({ theme }) => darken(0.05, theme.codeBlock.backgroundColor)}; border-radius: 5px; min-width: 60px; font-size: 0.9em; @@ -58,7 +58,7 @@ export const Tabs = styled(ReactTabs)` } } > .react-tabs__tab-panel { - background: ${({ theme }) => theme.codeSample.backgroundColor}; + background: ${({ theme }) => theme.codeBlock.backgroundColor}; & > div, & > pre { padding: ${props => props.theme.spacing.unit * 4}px; diff --git a/src/components/Endpoint/styled.elements.ts b/src/components/Endpoint/styled.elements.ts index f00a032b..b579b9fb 100644 --- a/src/components/Endpoint/styled.elements.ts +++ b/src/components/Endpoint/styled.elements.ts @@ -18,7 +18,7 @@ export const EndpointInfo = styled.div<{ expanded?: boolean; inverted?: boolean padding: 10px 30px 10px ${props => (props.inverted ? '10px' : '20px')}; border-radius: ${props => (props.inverted ? '0' : '4px 4px 0 0')}; background-color: ${props => - props.inverted ? 'transparent' : props.theme.codeSample.backgroundColor}; + props.inverted ? 'transparent' : props.theme.codeBlock.backgroundColor}; display: flex; white-space: nowrap; align-items: center; diff --git a/src/components/Markdown/styled.elements.tsx b/src/components/Markdown/styled.elements.tsx index 321a41e2..6fce553d 100644 --- a/src/components/Markdown/styled.elements.tsx +++ b/src/components/Markdown/styled.elements.tsx @@ -82,7 +82,7 @@ export const StyledMarkdownBlock = styled( pre { font-family: ${props => props.theme.typography.code.fontFamily}; white-space:${({ theme }) => (theme.typography.code.wrap ? 'pre-wrap' : 'pre')}; - background-color: #263238; + background-color: ${({ theme }) => theme.codeBlock.backgroundColor}; color: white; padding: ${props => props.theme.spacing.unit * 4}px; overflow-x: auto; diff --git a/src/components/Redoc/styled.elements.tsx b/src/components/Redoc/styled.elements.tsx index ebb30df1..4118384e 100644 --- a/src/components/Redoc/styled.elements.tsx +++ b/src/components/Redoc/styled.elements.tsx @@ -29,7 +29,7 @@ export const ApiContentWrap = styled.div` z-index: 1; position: relative; overflow: hidden; - width: calc(100% - ${props => props.theme.menu.width}); + width: calc(100% - ${props => props.theme.sidebar.width}); ${media.lessThan('small', true)` width: 100%; `}; @@ -46,7 +46,7 @@ export const BackgroundStub = styled.div` width: ${({ theme }) => { if (theme.rightPanel.width.endsWith('%')) { const percents = parseInt(theme.rightPanel.width, 10); - return `calc((100% - ${theme.menu.width}) * ${percents / 100})`; + return `calc((100% - ${theme.sidebar.width}) * ${percents / 100})`; } else { return theme.rightPanel.width; } diff --git a/src/components/SchemaDefinition/SchemaDefinition.tsx b/src/components/SchemaDefinition/SchemaDefinition.tsx index 9515cf99..69308dfd 100644 --- a/src/components/SchemaDefinition/SchemaDefinition.tsx +++ b/src/components/SchemaDefinition/SchemaDefinition.tsx @@ -80,7 +80,7 @@ export class SchemaDefinition extends React.PureComponent theme.codeSample.backgroundColor}; + background: ${({ theme }) => theme.codeBlock.backgroundColor}; & > div, & > pre { padding: ${props => props.theme.spacing.unit * 4}px; diff --git a/src/components/SearchBox/styled.elements.tsx b/src/components/SearchBox/styled.elements.tsx index 5517bb78..22aae826 100644 --- a/src/components/SearchBox/styled.elements.tsx +++ b/src/components/SearchBox/styled.elements.tsx @@ -19,14 +19,14 @@ export const SearchInput = styled.input.attrs(() => ({ border: 0; border-bottom: 1px solid ${({ theme }) => - (getLuminance(theme.menu.backgroundColor) > 0.5 ? darken : lighten)( + (getLuminance(theme.sidebar.backgroundColor) > 0.5 ? darken : lighten)( 0.1, - theme.menu.backgroundColor, + theme.sidebar.backgroundColor, )}; font-family: ${({ theme }) => theme.typography.fontFamily}; font-weight: bold; font-size: 13px; - color: ${props => props.theme.menu.textColor}; + color: ${props => props.theme.sidebar.textColor}; background-color: transparent; outline: none; `; @@ -51,18 +51,18 @@ export const SearchIcon = styled((props: { className?: string }) => ( width: 0.9em; path { - fill: ${props => props.theme.menu.textColor}; + fill: ${props => props.theme.sidebar.textColor}; } `; export const SearchResultsBox = styled.div` padding: ${props => props.theme.spacing.unit}px 0; - background-color: ${({ theme }) => darken(0.05, theme.menu.backgroundColor)}}; - color: ${props => props.theme.menu.textColor}; + background-color: ${({ theme }) => darken(0.05, theme.sidebar.backgroundColor)}}; + color: ${props => props.theme.sidebar.textColor}; min-height: 150px; max-height: 250px; - border-top: ${({ theme }) => darken(0.1, theme.menu.backgroundColor)}}; - border-bottom: ${({ theme }) => darken(0.1, theme.menu.backgroundColor)}}; + border-top: ${({ theme }) => darken(0.1, theme.sidebar.backgroundColor)}}; + border-bottom: ${({ theme }) => darken(0.1, theme.sidebar.backgroundColor)}}; margin-top: 10px; line-height: 1.4; font-size: 0.9em; @@ -73,7 +73,7 @@ export const SearchResultsBox = styled.div` &:hover, &.active { - background-color: ${({ theme }) => darken(0.1, theme.menu.backgroundColor)}; + background-color: ${({ theme }) => darken(0.1, theme.sidebar.backgroundColor)}; } > svg { diff --git a/src/components/SideMenu/styled.elements.ts b/src/components/SideMenu/styled.elements.ts index 9e74b800..f400b170 100644 --- a/src/components/SideMenu/styled.elements.ts +++ b/src/components/SideMenu/styled.elements.ts @@ -2,7 +2,7 @@ import * as classnames from 'classnames'; import { darken } from 'polished'; import { deprecatedCss, ShelfIcon } from '../../common-elements'; -import styled, { css } from '../../styled-components'; +import styled, { css, ResolvedThemeInterface } from '../../styled-components'; export const OperationBadge = styled.span.attrs((props: { type: string }) => ({ className: `operation-type ${props.type}`, @@ -62,11 +62,11 @@ export const OperationBadge = styled.span.attrs((props: { type: string }) => ({ } `; -function menuItemActiveBg(depth, { theme }): string { +function menuItemActiveBg(depth, { theme }: { theme: ResolvedThemeInterface }): string { if (depth > 1) { - return darken(0.1, theme.menu.backgroundColor); + return darken(0.1, theme.sidebar.backgroundColor); } else if (depth === 1) { - return darken(0.05, theme.menu.backgroundColor); + return darken(0.05, theme.sidebar.backgroundColor); } else { return ''; } @@ -94,21 +94,21 @@ export const MenuItemLi = styled.li<{ depth: number }>` export const menuItemDepth = { 0: css` opacity: 0.7; - text-transform: ${({ theme }) => theme.menu.groupItems.textTransform}; + text-transform: ${({ theme }) => theme.sidebar.groupItems.textTransform}; font-size: 0.8em; padding-bottom: 0; cursor: default; - color: ${props => props.theme.menu.textColor}; + color: ${props => props.theme.sidebar.textColor}; `, 1: css` font-size: 0.929em; - text-transform: ${({ theme }) => theme.menu.level1Items.textTransform}; + text-transform: ${({ theme }) => theme.sidebar.level1Items.textTransform}; &:hover { - color: ${props => props.theme.menu.activeTextColor}; + color: ${props => props.theme.sidebar.activeTextColor}; } `, 2: css` - color: ${props => props.theme.menu.textColor}; + color: ${props => props.theme.sidebar.textColor}; `, }; @@ -126,7 +126,8 @@ export const MenuItemLabel = styled.label.attrs((props: MenuItemLabelType) => ({ }), }))` cursor: pointer; - color: ${props => (props.active ? props.theme.menu.activeTextColor : props.theme.menu.textColor)}; + color: ${props => + props.active ? props.theme.sidebar.activeTextColor : props.theme.sidebar.textColor}; margin: 0; padding: 12.5px ${props => props.theme.spacing.unit * 4}px; ${({ depth, type, theme }) => @@ -144,10 +145,10 @@ export const MenuItemLabel = styled.label.attrs((props: MenuItemLabelType) => ({ } ${ShelfIcon} { - height: ${({ theme }) => theme.menu.arrow.size}; - width: ${({ theme }) => theme.menu.arrow.size}; + height: ${({ theme }) => theme.sidebar.arrow.size}; + width: ${({ theme }) => theme.sidebar.arrow.size}; polygon { - fill: ${({ theme }) => theme.menu.arrow.color}; + fill: ${({ theme }) => theme.sidebar.arrow.color}; } } `; @@ -172,8 +173,8 @@ export const RedocAttribution = styled.div` a, a:visited, a:hover { - color: ${theme.menu.textColor} !important; - border-top: 1px solid ${darken(0.1, theme.menu.backgroundColor)}; + color: ${theme.sidebar.textColor} !important; + border-top: 1px solid ${darken(0.1, theme.sidebar.backgroundColor)}; padding: ${theme.spacing.unit}px 0; display: block; } diff --git a/src/components/StickySidebar/StickyResponsiveSidebar.tsx b/src/components/StickySidebar/StickyResponsiveSidebar.tsx index 6031e676..45b70e2b 100644 --- a/src/components/StickySidebar/StickyResponsiveSidebar.tsx +++ b/src/components/StickySidebar/StickyResponsiveSidebar.tsx @@ -26,8 +26,8 @@ export interface StickySidebarState { const stickyfill = Stickyfill && Stickyfill(); const StyledStickySidebar = styled.div<{ open?: boolean }>` - width: ${props => props.theme.menu.width}; - background-color: ${props => props.theme.menu.backgroundColor}; + width: ${props => props.theme.sidebar.width}; + background-color: ${props => props.theme.sidebar.backgroundColor}; overflow: hidden; display: flex; flex-direction: column; @@ -44,7 +44,7 @@ const StyledStickySidebar = styled.div<{ open?: boolean }>` position: fixed; z-index: 20; width: 100%; - background: ${({ theme }) => theme.menu.backgroundColor}; + background: ${({ theme }) => theme.sidebar.backgroundColor}; display: ${props => (props.open ? 'flex' : 'none')}; `}; diff --git a/src/services/RedocNormalizedOptions.ts b/src/services/RedocNormalizedOptions.ts index 219ad286..8867855b 100644 --- a/src/services/RedocNormalizedOptions.ts +++ b/src/services/RedocNormalizedOptions.ts @@ -113,14 +113,14 @@ export class RedocNormalizedOptions { } if (typeof value !== 'string') { - return value + return value; } switch (value) { case 'true': - return true + return true; case 'false': - return false + return false; default: return value.split(',').map(ext => ext.trim()); } @@ -179,6 +179,18 @@ export class RedocNormalizedOptions { constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) { raw = { ...defaults, ...raw }; const hook = raw.theme && raw.theme.extensionsHook; + + // migrate from old theme + if ((raw.theme as any)?.menu && !raw.theme?.sidebar) { + console.warn('Theme setting "menu" is deprecated. Rename to "sidebar"'); + raw.theme!.sidebar = (raw.theme as any).menu; + } + + if ((raw.theme as any)?.codeSample && !raw.theme?.codeBlock) { + console.warn('Theme setting "codeSample" is deprecated. Rename to "codeBlock"'); + raw.theme!.codeBlock = (raw.theme as any).codeSample; + } + this.theme = resolveTheme( mergeObjects({} as any, defaultTheme, { ...raw.theme, extensionsHook: undefined }), ); diff --git a/src/theme.ts b/src/theme.ts index 53116ae5..3181808a 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -20,13 +20,13 @@ const defaultTheme: ThemeInterface = { contrastText: ({ colors }) => readableColor(colors.primary.main), }, success: { - main: '#00aa13', - light: ({ colors }) => lighten(colors.tonalOffset, colors.success.main), + main: '#37d247', + light: ({ colors }) => lighten(colors.tonalOffset * 2, colors.success.main), dark: ({ colors }) => darken(colors.tonalOffset, colors.success.main), contrastText: ({ colors }) => readableColor(colors.success.main), }, warning: { - main: '#d4ad03', + main: '#ffa500', light: ({ colors }) => lighten(colors.tonalOffset, colors.warning.main), dark: ({ colors }) => darken(colors.tonalOffset, colors.warning.main), contrastText: '#ffffff', @@ -55,7 +55,7 @@ const defaultTheme: ThemeInterface = { backgroundColor: ({ colors }) => transparentize(0.9, colors.error.main), }, redirect: { - color: '#ffa500', + color: ({ colors }) => colors.warning.main, backgroundColor: ({ colors }) => transparentize(0.9, colors.responses.redirect.color), }, info: { @@ -122,13 +122,13 @@ const defaultTheme: ThemeInterface = { hover: ({ typography }) => lighten(0.2, typography.links.color), }, }, - menu: { + sidebar: { width: '260px', backgroundColor: '#fafafa', textColor: '#333333', activeTextColor: theme => - theme.menu.textColor !== defaultTheme.menu!.textColor - ? theme.menu.textColor + theme.sidebar.textColor !== defaultTheme.sidebar!.textColor + ? theme.sidebar.textColor : theme.colors.primary.main, groupItems: { textTransform: 'uppercase', @@ -138,12 +138,12 @@ const defaultTheme: ThemeInterface = { }, arrow: { size: '1.5em', - color: theme => theme.menu.textColor, + color: theme => theme.sidebar.textColor, }, }, logo: { - maxHeight: ({ menu }) => menu.width, - maxWidth: ({ menu }) => menu.width, + maxHeight: ({ sidebar: menu }) => menu.width, + maxWidth: ({ sidebar: menu }) => menu.width, gutter: '2px', }, rightPanel: { @@ -151,7 +151,7 @@ const defaultTheme: ThemeInterface = { width: '40%', textColor: '#ffffff', }, - codeSample: { + codeBlock: { backgroundColor: ({ rightPanel }) => darken(0.1, rightPanel.backgroundColor), }, }; @@ -296,7 +296,7 @@ export interface ResolvedThemeInterface { hover: string; }; }; - menu: { + sidebar: { width: string; backgroundColor: string; textColor: string; @@ -322,7 +322,7 @@ export interface ResolvedThemeInterface { textColor: string; width: string; }; - codeSample: { + codeBlock: { backgroundColor: string; }; From 89054dae6c5428c673c47eea7bdbfc7a201e89f2 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 27 Mar 2020 19:01:18 +0200 Subject: [PATCH 6/8] =?UTF-8?q?chore:=20Release=202.0.0-rc.25=20?= =?UTF-8?q?=F0=9F=94=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 17 +++++++++++++++++ package.json | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ad35406..e5719366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +# [2.0.0-rc.25](https://github.com/Redocly/redoc/compare/v2.0.0-rc.24...v2.0.0-rc.25) (2020-03-27) + + +### Bug Fixes + +* do not collapse top level on Collapse All in json samples ([#1209](https://github.com/Redocly/redoc/issues/1209)) ([830371b](https://github.com/Redocly/redoc/commit/830371b5d1edf4ba7a138b3b3d78148d020e0349)) +* fix passing boolean value to showExtensions options ([#1211](https://github.com/Redocly/redoc/issues/1211)) ([c6eaa02](https://github.com/Redocly/redoc/commit/c6eaa0281bb0f62b019c865e4aefb863ce84d628)) +* improve names for some theme settings ([a0bd27c](https://github.com/Redocly/redoc/commit/a0bd27c75427a39abc9c753b0654678eed2f3851)) +* sort discriminator entries by mapping order ([#1216](https://github.com/Redocly/redoc/issues/1216)) ([ac4f915](https://github.com/Redocly/redoc/commit/ac4f915494f289d1c97ffdfe3af59efd94734f8c)) + + +### Features + +* add x-explicitMappingOnly extension ([#1215](https://github.com/Redocly/redoc/issues/1215)) ([ea5b0aa](https://github.com/Redocly/redoc/commit/ea5b0aabf9133d11d3a8fcb79f9515d21e0d7ac0)) + + + # [2.0.0-rc.24](https://github.com/Redocly/redoc/compare/v2.0.0-rc.23...v2.0.0-rc.24) (2020-03-17) diff --git a/package.json b/package.json index 869f0d6e..6e502f8f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redoc", - "version": "2.0.0-rc.24", + "version": "2.0.0-rc.25", "description": "ReDoc", "repository": { "type": "git", From 3908a7c46448d277b82318659cdea65db52f9e70 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 29 Mar 2020 20:19:23 +0300 Subject: [PATCH 7/8] fix: crash to wrong spelling in localeCompare fixes #1218 --- src/services/models/Schema.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/services/models/Schema.ts b/src/services/models/Schema.ts index 722c2bb7..49e89f12 100644 --- a/src/services/models/Schema.ts +++ b/src/services/models/Schema.ts @@ -261,7 +261,9 @@ export class SchemaModel { } } - const inversedMapping = isLimitedToMapping ? { ...explicitInversedMapping } : { ...implicitInversedMapping, ...explicitInversedMapping }; + const inversedMapping = isLimitedToMapping + ? { ...explicitInversedMapping } + : { ...implicitInversedMapping, ...explicitInversedMapping }; let refs: Array<{ $ref; name }> = []; @@ -276,7 +278,7 @@ export class SchemaModel { } } - // Make the listing respects the mapping + // Make the listing respects the mapping // in case a mapping is defined, the user usually wants to have the order shown // as it was defined in the yaml. This will sort the names given the provided // mapping (if provided). @@ -292,7 +294,7 @@ export class SchemaModel { if (indexLeft < 0 && indexRight < 0) { // out of mapping, order by name - return left.name.localCompare(right.name); + return left.name.localeCompare(right.name); } else if (indexLeft < 0) { // the right is found, so mapping wins return 1; From 5bd2e6227b7b34c22c4e58c3eb3d38bb9d142076 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 29 Mar 2020 20:20:36 +0300 Subject: [PATCH 8/8] =?UTF-8?q?chore:=20Release=202.0.0-rc.26=20?= =?UTF-8?q?=F0=9F=94=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5719366..eb16f2d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# [2.0.0-rc.26](https://github.com/Redocly/redoc/compare/v2.0.0-rc.25...v2.0.0-rc.26) (2020-03-29) + + +### Bug Fixes + +* crash to wrong spelling in localeCompare ([3908a7c](https://github.com/Redocly/redoc/commit/3908a7c46448d277b82318659cdea65db52f9e70)), closes [#1218](https://github.com/Redocly/redoc/issues/1218) + + + # [2.0.0-rc.25](https://github.com/Redocly/redoc/compare/v2.0.0-rc.24...v2.0.0-rc.25) (2020-03-27) diff --git a/package.json b/package.json index 6e502f8f..a126fac2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redoc", - "version": "2.0.0-rc.25", + "version": "2.0.0-rc.26", "description": "ReDoc", "repository": { "type": "git",