mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 21:54:53 +03:00
chore: add new option hideSchemaPattern
This commit is contained in:
parent
d12e410d99
commit
c4f2eebfca
|
@ -46,7 +46,7 @@ export class FieldDetails extends React.PureComponent<FieldProps, { patternShown
|
||||||
render() {
|
render() {
|
||||||
const { showExamples, field, renderDiscriminatorSwitch } = this.props;
|
const { showExamples, field, renderDiscriminatorSwitch } = this.props;
|
||||||
const { patternShown } = this.state;
|
const { patternShown } = this.state;
|
||||||
const { enumSkipQuotes, hideSchemaTitles } = this.context;
|
const { enumSkipQuotes, hideSchemaTitles, hideSchemaPattern } = this.context;
|
||||||
|
|
||||||
const { schema, description, example, deprecated, examples } = field;
|
const { schema, description, example, deprecated, examples } = field;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ export class FieldDetails extends React.PureComponent<FieldProps, { patternShown
|
||||||
{schema.title && !hideSchemaTitles && <TypeTitle> ({schema.title}) </TypeTitle>}
|
{schema.title && !hideSchemaTitles && <TypeTitle> ({schema.title}) </TypeTitle>}
|
||||||
<ConstraintsView constraints={schema.constraints} />
|
<ConstraintsView constraints={schema.constraints} />
|
||||||
{schema.nullable && <NullableLabel> {l('nullable')} </NullableLabel>}
|
{schema.nullable && <NullableLabel> {l('nullable')} </NullableLabel>}
|
||||||
{schema.pattern && (
|
{schema.pattern && !hideSchemaPattern && (
|
||||||
<>
|
<>
|
||||||
<PatternLabel>
|
<PatternLabel>
|
||||||
{patternShown || schema.pattern.length < MAX_PATTERN_LENGTH
|
{patternShown || schema.pattern.length < MAX_PATTERN_LENGTH
|
||||||
|
|
|
@ -41,6 +41,7 @@ export interface RedocRawOptions {
|
||||||
expandDefaultServerVariables?: boolean;
|
expandDefaultServerVariables?: boolean;
|
||||||
maxDisplayedEnumValues?: number;
|
maxDisplayedEnumValues?: number;
|
||||||
ignoreNamedSchemas?: string[] | string;
|
ignoreNamedSchemas?: string[] | string;
|
||||||
|
hideSchemaPattern?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
||||||
|
@ -194,6 +195,7 @@ export class RedocNormalizedOptions {
|
||||||
maxDisplayedEnumValues?: number;
|
maxDisplayedEnumValues?: number;
|
||||||
|
|
||||||
ignoreNamedSchemas: Set<string>;
|
ignoreNamedSchemas: Set<string>;
|
||||||
|
hideSchemaPattern: boolean;
|
||||||
|
|
||||||
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
||||||
raw = { ...defaults, ...raw };
|
raw = { ...defaults, ...raw };
|
||||||
|
@ -250,7 +252,10 @@ export class RedocNormalizedOptions {
|
||||||
|
|
||||||
this.expandDefaultServerVariables = argValueToBoolean(raw.expandDefaultServerVariables);
|
this.expandDefaultServerVariables = argValueToBoolean(raw.expandDefaultServerVariables);
|
||||||
this.maxDisplayedEnumValues = argValueToNumber(raw.maxDisplayedEnumValues);
|
this.maxDisplayedEnumValues = argValueToNumber(raw.maxDisplayedEnumValues);
|
||||||
const ignoreNamedSchemas = Array.isArray(raw.ignoreNamedSchemas) ? raw.ignoreNamedSchemas : raw.ignoreNamedSchemas?.split(',').map(s => s.trim());
|
const ignoreNamedSchemas = Array.isArray(raw.ignoreNamedSchemas)
|
||||||
|
? raw.ignoreNamedSchemas
|
||||||
|
: raw.ignoreNamedSchemas?.split(',').map((s) => s.trim());
|
||||||
this.ignoreNamedSchemas = new Set(ignoreNamedSchemas);
|
this.ignoreNamedSchemas = new Set(ignoreNamedSchemas);
|
||||||
|
this.hideSchemaPattern = argValueToBoolean(raw.hideSchemaPattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user