mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-01 19:00:21 +03:00
DOP-3463: Add option to suppress incompatible types warning (#6)
This commit is contained in:
parent
64072db4c5
commit
4667dfaf0e
|
@ -56,8 +56,8 @@ export class Redoc extends React.Component<RedocProps> {
|
||||||
<StickyResponsiveSidebar menu={menu} className="menu-content">
|
<StickyResponsiveSidebar menu={menu} className="menu-content">
|
||||||
<ApiLogo info={spec.info} />
|
<ApiLogo info={spec.info} />
|
||||||
<SideMenuBackButton
|
<SideMenuBackButton
|
||||||
backNavigationPath={options.customOptions?.backNavigationPath}
|
backNavigationPath={options.backNavigationPath}
|
||||||
siteTitle={options.customOptions?.siteTitle}
|
siteTitle={options.siteTitle}
|
||||||
/>
|
/>
|
||||||
<SideMenuTitle>{store.spec.info.title}</SideMenuTitle>
|
<SideMenuTitle>{store.spec.info.title}</SideMenuTitle>
|
||||||
{(!options.disableSearch && (
|
{(!options.disableSearch && (
|
||||||
|
|
|
@ -76,7 +76,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"minItems": undefined,
|
"minItems": undefined,
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"customOptions": Object {},
|
"backNavigationPath": undefined,
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
"downloadDefinitionUrl": undefined,
|
"downloadDefinitionUrl": undefined,
|
||||||
"downloadFileName": undefined,
|
"downloadFileName": undefined,
|
||||||
|
@ -92,6 +92,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
"hideSecuritySection": false,
|
"hideSecuritySection": false,
|
||||||
"hideSingleRequestSampleTab": false,
|
"hideSingleRequestSampleTab": false,
|
||||||
|
"ignoreIncompatibleTypes": false,
|
||||||
"ignoreNamedSchemas": Set {},
|
"ignoreNamedSchemas": Set {},
|
||||||
"jsonSampleExpandLevel": 2,
|
"jsonSampleExpandLevel": 2,
|
||||||
"maxDisplayedEnumValues": undefined,
|
"maxDisplayedEnumValues": undefined,
|
||||||
|
@ -111,6 +112,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"showWebhookVerb": false,
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
|
"siteTitle": undefined,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
"sortOperationsAlphabetically": false,
|
"sortOperationsAlphabetically": false,
|
||||||
"sortPropsAlphabetically": false,
|
"sortPropsAlphabetically": false,
|
||||||
|
@ -407,7 +409,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"minItems": undefined,
|
"minItems": undefined,
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"customOptions": Object {},
|
"backNavigationPath": undefined,
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
"downloadDefinitionUrl": undefined,
|
"downloadDefinitionUrl": undefined,
|
||||||
"downloadFileName": undefined,
|
"downloadFileName": undefined,
|
||||||
|
@ -423,6 +425,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
"hideSecuritySection": false,
|
"hideSecuritySection": false,
|
||||||
"hideSingleRequestSampleTab": false,
|
"hideSingleRequestSampleTab": false,
|
||||||
|
"ignoreIncompatibleTypes": false,
|
||||||
"ignoreNamedSchemas": Set {},
|
"ignoreNamedSchemas": Set {},
|
||||||
"jsonSampleExpandLevel": 2,
|
"jsonSampleExpandLevel": 2,
|
||||||
"maxDisplayedEnumValues": undefined,
|
"maxDisplayedEnumValues": undefined,
|
||||||
|
@ -442,6 +445,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"showWebhookVerb": false,
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
|
"siteTitle": undefined,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
"sortOperationsAlphabetically": false,
|
"sortOperationsAlphabetically": false,
|
||||||
"sortPropsAlphabetically": false,
|
"sortPropsAlphabetically": false,
|
||||||
|
@ -725,7 +729,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"minItems": undefined,
|
"minItems": undefined,
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"customOptions": Object {},
|
"backNavigationPath": undefined,
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
"downloadDefinitionUrl": undefined,
|
"downloadDefinitionUrl": undefined,
|
||||||
"downloadFileName": undefined,
|
"downloadFileName": undefined,
|
||||||
|
@ -741,6 +745,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
"hideSecuritySection": false,
|
"hideSecuritySection": false,
|
||||||
"hideSingleRequestSampleTab": false,
|
"hideSingleRequestSampleTab": false,
|
||||||
|
"ignoreIncompatibleTypes": false,
|
||||||
"ignoreNamedSchemas": Set {},
|
"ignoreNamedSchemas": Set {},
|
||||||
"jsonSampleExpandLevel": 2,
|
"jsonSampleExpandLevel": 2,
|
||||||
"maxDisplayedEnumValues": undefined,
|
"maxDisplayedEnumValues": undefined,
|
||||||
|
@ -760,6 +765,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"showWebhookVerb": false,
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
|
"siteTitle": undefined,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
"sortOperationsAlphabetically": false,
|
"sortOperationsAlphabetically": false,
|
||||||
"sortPropsAlphabetically": false,
|
"sortPropsAlphabetically": false,
|
||||||
|
@ -1105,7 +1111,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"minItems": undefined,
|
"minItems": undefined,
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"customOptions": Object {},
|
"backNavigationPath": undefined,
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
"downloadDefinitionUrl": undefined,
|
"downloadDefinitionUrl": undefined,
|
||||||
"downloadFileName": undefined,
|
"downloadFileName": undefined,
|
||||||
|
@ -1121,6 +1127,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
"hideSecuritySection": false,
|
"hideSecuritySection": false,
|
||||||
"hideSingleRequestSampleTab": false,
|
"hideSingleRequestSampleTab": false,
|
||||||
|
"ignoreIncompatibleTypes": false,
|
||||||
"ignoreNamedSchemas": Set {},
|
"ignoreNamedSchemas": Set {},
|
||||||
"jsonSampleExpandLevel": 2,
|
"jsonSampleExpandLevel": 2,
|
||||||
"maxDisplayedEnumValues": undefined,
|
"maxDisplayedEnumValues": undefined,
|
||||||
|
@ -1140,6 +1147,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"showWebhookVerb": false,
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
|
"siteTitle": undefined,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
"sortOperationsAlphabetically": false,
|
"sortOperationsAlphabetically": false,
|
||||||
"sortPropsAlphabetically": false,
|
"sortPropsAlphabetically": false,
|
||||||
|
@ -1448,7 +1456,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"minItems": undefined,
|
"minItems": undefined,
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"customOptions": Object {},
|
"backNavigationPath": undefined,
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
"downloadDefinitionUrl": undefined,
|
"downloadDefinitionUrl": undefined,
|
||||||
"downloadFileName": undefined,
|
"downloadFileName": undefined,
|
||||||
|
@ -1464,6 +1472,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
"hideSecuritySection": false,
|
"hideSecuritySection": false,
|
||||||
"hideSingleRequestSampleTab": false,
|
"hideSingleRequestSampleTab": false,
|
||||||
|
"ignoreIncompatibleTypes": false,
|
||||||
"ignoreNamedSchemas": Set {},
|
"ignoreNamedSchemas": Set {},
|
||||||
"jsonSampleExpandLevel": 2,
|
"jsonSampleExpandLevel": 2,
|
||||||
"maxDisplayedEnumValues": undefined,
|
"maxDisplayedEnumValues": undefined,
|
||||||
|
@ -1483,6 +1492,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"showWebhookVerb": false,
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
|
"siteTitle": undefined,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
"sortOperationsAlphabetically": false,
|
"sortOperationsAlphabetically": false,
|
||||||
"sortPropsAlphabetically": false,
|
"sortPropsAlphabetically": false,
|
||||||
|
@ -1762,7 +1772,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"minItems": undefined,
|
"minItems": undefined,
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"customOptions": Object {},
|
"backNavigationPath": undefined,
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
"downloadDefinitionUrl": undefined,
|
"downloadDefinitionUrl": undefined,
|
||||||
"downloadFileName": undefined,
|
"downloadFileName": undefined,
|
||||||
|
@ -1778,6 +1788,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
"hideSecuritySection": false,
|
"hideSecuritySection": false,
|
||||||
"hideSingleRequestSampleTab": false,
|
"hideSingleRequestSampleTab": false,
|
||||||
|
"ignoreIncompatibleTypes": false,
|
||||||
"ignoreNamedSchemas": Set {},
|
"ignoreNamedSchemas": Set {},
|
||||||
"jsonSampleExpandLevel": 2,
|
"jsonSampleExpandLevel": 2,
|
||||||
"maxDisplayedEnumValues": undefined,
|
"maxDisplayedEnumValues": undefined,
|
||||||
|
@ -1797,6 +1808,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"showWebhookVerb": false,
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
|
"siteTitle": undefined,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
"sortOperationsAlphabetically": false,
|
"sortOperationsAlphabetically": false,
|
||||||
"sortPropsAlphabetically": false,
|
"sortPropsAlphabetically": false,
|
||||||
|
@ -2101,7 +2113,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
],
|
],
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"customOptions": Object {},
|
"backNavigationPath": undefined,
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
"downloadDefinitionUrl": undefined,
|
"downloadDefinitionUrl": undefined,
|
||||||
"downloadFileName": undefined,
|
"downloadFileName": undefined,
|
||||||
|
@ -2117,6 +2129,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
"hideSecuritySection": false,
|
"hideSecuritySection": false,
|
||||||
"hideSingleRequestSampleTab": false,
|
"hideSingleRequestSampleTab": false,
|
||||||
|
"ignoreIncompatibleTypes": false,
|
||||||
"ignoreNamedSchemas": Set {},
|
"ignoreNamedSchemas": Set {},
|
||||||
"jsonSampleExpandLevel": 2,
|
"jsonSampleExpandLevel": 2,
|
||||||
"maxDisplayedEnumValues": undefined,
|
"maxDisplayedEnumValues": undefined,
|
||||||
|
@ -2136,6 +2149,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"showWebhookVerb": false,
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
|
"siteTitle": undefined,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
"sortOperationsAlphabetically": false,
|
"sortOperationsAlphabetically": false,
|
||||||
"sortPropsAlphabetically": false,
|
"sortPropsAlphabetically": false,
|
||||||
|
@ -2470,7 +2484,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"minItems": undefined,
|
"minItems": undefined,
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"customOptions": Object {},
|
"backNavigationPath": undefined,
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
"downloadDefinitionUrl": undefined,
|
"downloadDefinitionUrl": undefined,
|
||||||
"downloadFileName": undefined,
|
"downloadFileName": undefined,
|
||||||
|
@ -2486,6 +2500,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
"hideSecuritySection": false,
|
"hideSecuritySection": false,
|
||||||
"hideSingleRequestSampleTab": false,
|
"hideSingleRequestSampleTab": false,
|
||||||
|
"ignoreIncompatibleTypes": false,
|
||||||
"ignoreNamedSchemas": Set {},
|
"ignoreNamedSchemas": Set {},
|
||||||
"jsonSampleExpandLevel": 2,
|
"jsonSampleExpandLevel": 2,
|
||||||
"maxDisplayedEnumValues": undefined,
|
"maxDisplayedEnumValues": undefined,
|
||||||
|
@ -2505,6 +2520,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"showWebhookVerb": false,
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
|
"siteTitle": undefined,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
"sortOperationsAlphabetically": false,
|
"sortOperationsAlphabetically": false,
|
||||||
"sortPropsAlphabetically": false,
|
"sortPropsAlphabetically": false,
|
||||||
|
@ -2801,7 +2817,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"minItems": undefined,
|
"minItems": undefined,
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"customOptions": Object {},
|
"backNavigationPath": undefined,
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
"downloadDefinitionUrl": undefined,
|
"downloadDefinitionUrl": undefined,
|
||||||
"downloadFileName": undefined,
|
"downloadFileName": undefined,
|
||||||
|
@ -2817,6 +2833,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
"hideSecuritySection": false,
|
"hideSecuritySection": false,
|
||||||
"hideSingleRequestSampleTab": false,
|
"hideSingleRequestSampleTab": false,
|
||||||
|
"ignoreIncompatibleTypes": false,
|
||||||
"ignoreNamedSchemas": Set {},
|
"ignoreNamedSchemas": Set {},
|
||||||
"jsonSampleExpandLevel": 2,
|
"jsonSampleExpandLevel": 2,
|
||||||
"maxDisplayedEnumValues": undefined,
|
"maxDisplayedEnumValues": undefined,
|
||||||
|
@ -2836,6 +2853,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"showWebhookVerb": false,
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
|
"siteTitle": undefined,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
"sortOperationsAlphabetically": false,
|
"sortOperationsAlphabetically": false,
|
||||||
"sortPropsAlphabetically": false,
|
"sortPropsAlphabetically": false,
|
||||||
|
@ -3119,7 +3137,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"minItems": undefined,
|
"minItems": undefined,
|
||||||
"options": RedocNormalizedOptions {
|
"options": RedocNormalizedOptions {
|
||||||
"allowedMdComponents": Object {},
|
"allowedMdComponents": Object {},
|
||||||
"customOptions": Object {},
|
"backNavigationPath": undefined,
|
||||||
"disableSearch": false,
|
"disableSearch": false,
|
||||||
"downloadDefinitionUrl": undefined,
|
"downloadDefinitionUrl": undefined,
|
||||||
"downloadFileName": undefined,
|
"downloadFileName": undefined,
|
||||||
|
@ -3135,6 +3153,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
"hideSecuritySection": false,
|
"hideSecuritySection": false,
|
||||||
"hideSingleRequestSampleTab": false,
|
"hideSingleRequestSampleTab": false,
|
||||||
|
"ignoreIncompatibleTypes": false,
|
||||||
"ignoreNamedSchemas": Set {},
|
"ignoreNamedSchemas": Set {},
|
||||||
"jsonSampleExpandLevel": 2,
|
"jsonSampleExpandLevel": 2,
|
||||||
"maxDisplayedEnumValues": undefined,
|
"maxDisplayedEnumValues": undefined,
|
||||||
|
@ -3154,6 +3173,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"showWebhookVerb": false,
|
"showWebhookVerb": false,
|
||||||
"sideNavStyle": "summary-only",
|
"sideNavStyle": "summary-only",
|
||||||
"simpleOneOfTypeLabel": false,
|
"simpleOneOfTypeLabel": false,
|
||||||
|
"siteTitle": undefined,
|
||||||
"sortEnumValuesAlphabetically": false,
|
"sortEnumValuesAlphabetically": false,
|
||||||
"sortOperationsAlphabetically": false,
|
"sortOperationsAlphabetically": false,
|
||||||
"sortPropsAlphabetically": false,
|
"sortPropsAlphabetically": false,
|
||||||
|
|
|
@ -242,7 +242,12 @@ export class OpenAPIParser {
|
||||||
...otherConstraints
|
...otherConstraints
|
||||||
} = subSchema;
|
} = subSchema;
|
||||||
|
|
||||||
if (receiver.type !== type && receiver.type !== undefined && type !== undefined) {
|
if (
|
||||||
|
receiver.type !== type &&
|
||||||
|
receiver.type !== undefined &&
|
||||||
|
type !== undefined &&
|
||||||
|
!this.options.ignoreIncompatibleTypes
|
||||||
|
) {
|
||||||
console.warn(`Incompatible types in allOf at "${$ref}": "${receiver.type}" and "${type}"`);
|
console.warn(`Incompatible types in allOf at "${$ref}": "${receiver.type}" and "${type}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,6 @@ import { setRedocLabels } from './Labels';
|
||||||
import { SideNavStyleEnum } from './types';
|
import { SideNavStyleEnum } from './types';
|
||||||
import type { LabelsConfigRaw, MDXComponentMeta } from './types';
|
import type { LabelsConfigRaw, MDXComponentMeta } from './types';
|
||||||
|
|
||||||
// Custom options needed by DOP. Add any custom options here.
|
|
||||||
interface CustomOptions {
|
|
||||||
backNavigationPath?: string;
|
|
||||||
siteTitle?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RedocRawOptions {
|
export interface RedocRawOptions {
|
||||||
theme?: ThemeInterface;
|
theme?: ThemeInterface;
|
||||||
scrollYOffset?: number | string | (() => number);
|
scrollYOffset?: number | string | (() => number);
|
||||||
|
@ -63,8 +57,10 @@ export interface RedocRawOptions {
|
||||||
minCharacterLengthToInitSearch?: number;
|
minCharacterLengthToInitSearch?: number;
|
||||||
showWebhookVerb?: boolean;
|
showWebhookVerb?: boolean;
|
||||||
|
|
||||||
// Custom options specific to DOP's use case
|
// Custom options specific to DOP's use case. Options expected by the CLI should be added here.
|
||||||
customOptions?: CustomOptions;
|
backNavigationPath?: string;
|
||||||
|
ignoreIncompatibleTypes?: boolean | string;
|
||||||
|
siteTitle?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
||||||
|
@ -268,7 +264,11 @@ export class RedocNormalizedOptions {
|
||||||
|
|
||||||
nonce?: string;
|
nonce?: string;
|
||||||
|
|
||||||
customOptions?: CustomOptions;
|
// Normalized custom options for DOP. Add custom options here if they are expected to
|
||||||
|
// be used by the component elsewhere.
|
||||||
|
backNavigationPath?: string;
|
||||||
|
ignoreIncompatibleTypes: boolean;
|
||||||
|
siteTitle?: string;
|
||||||
|
|
||||||
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
||||||
raw = { ...defaults, ...raw };
|
raw = { ...defaults, ...raw };
|
||||||
|
@ -347,7 +347,9 @@ export class RedocNormalizedOptions {
|
||||||
this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3;
|
this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3;
|
||||||
this.showWebhookVerb = argValueToBoolean(raw.showWebhookVerb);
|
this.showWebhookVerb = argValueToBoolean(raw.showWebhookVerb);
|
||||||
|
|
||||||
// No normalization needed for custom options at the moment. Expand if needed
|
// Normalization of custom DOP options
|
||||||
this.customOptions = raw.customOptions || {};
|
this.backNavigationPath = raw.backNavigationPath;
|
||||||
|
this.ignoreIncompatibleTypes = argValueToBoolean(raw.ignoreIncompatibleTypes);
|
||||||
|
this.siteTitle = raw.siteTitle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
46
src/services/__tests__/fixtures/oneOfIncompatibleTypes.json
Normal file
46
src/services/__tests__/fixtures/oneOfIncompatibleTypes.json
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
"openapi": "3.0.0",
|
||||||
|
"info": {
|
||||||
|
"version": "1.0",
|
||||||
|
"title": "Foo"
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"/test": {
|
||||||
|
"get": {
|
||||||
|
"summary": "This schema should invoke a warning because of incompatible types.",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/components/schemas/Schema1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"components": {
|
||||||
|
"schemas": {
|
||||||
|
"Schema1": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"foo": {
|
||||||
|
"type": "object",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,6 +45,32 @@ describe('Models', () => {
|
||||||
expect(schema.displayType).toBe('(Array of strings or numbers) or string');
|
expect(schema.displayType).toBe('(Array of strings or numbers) or string');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('incompatible type warnings', () => {
|
||||||
|
const spec = require('../fixtures/oneOfIncompatibleTypes.json');
|
||||||
|
let consoleWarnMock: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
consoleWarnMock = jest.spyOn(global.console, 'warn').mockImplementation();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
consoleWarnMock.mockClear();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('warnings are displayed in the console', () => {
|
||||||
|
parser = new OpenAPIParser(spec, undefined, opts);
|
||||||
|
new SchemaModel(parser, spec.components.schemas.Schema1, '', opts);
|
||||||
|
expect(consoleWarnMock).toBeCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('warnings are suppressed', () => {
|
||||||
|
const opts = new RedocNormalizedOptions({ ignoreIncompatibleTypes: true });
|
||||||
|
parser = new OpenAPIParser(spec, undefined, opts);
|
||||||
|
new SchemaModel(parser, spec.components.schemas.Schema1, '', opts);
|
||||||
|
expect(consoleWarnMock).not.toBeCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('schemaDefinition should resolve double ref', () => {
|
test('schemaDefinition should resolve double ref', () => {
|
||||||
const spec = require('../fixtures/3.1/schemaDefinition.json');
|
const spec = require('../fixtures/3.1/schemaDefinition.json');
|
||||||
parser = new OpenAPIParser(spec, undefined, opts);
|
parser = new OpenAPIParser(spec, undefined, opts);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user