feat: new option hideSchemaTitles

This commit is contained in:
Roman Hotsiy 2019-12-12 16:59:04 +02:00
parent 4a25aaef69
commit 11cc4c4c3e
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 5 additions and 2 deletions

View File

@ -27,7 +27,7 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
static contextType = OptionsContext; static contextType = OptionsContext;
render() { render() {
const { showExamples, field, renderDiscriminatorSwitch } = this.props; const { showExamples, field, renderDiscriminatorSwitch } = this.props;
const { enumSkipQuotes } = this.context; const { enumSkipQuotes, hideSchemaTitles } = this.context;
const { schema, description, example, deprecated } = field; const { schema, description, example, deprecated } = field;
@ -59,7 +59,7 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
&gt;{' '} &gt;{' '}
</TypeFormat> </TypeFormat>
)} )}
{schema.title && <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 && <PatternLabel> {schema.pattern} </PatternLabel>} {schema.pattern && <PatternLabel> {schema.pattern} </PatternLabel>}

View File

@ -24,6 +24,7 @@ export interface RedocRawOptions {
hideSingleRequestSampleTab?: boolean | string; hideSingleRequestSampleTab?: boolean | string;
menuToggle?: boolean | string; menuToggle?: boolean | string;
jsonSampleExpandLevel?: number | string | 'all'; jsonSampleExpandLevel?: number | string | 'all';
hideSchemaTitles?: boolean | string;
unstable_ignoreMimeParameters?: boolean; unstable_ignoreMimeParameters?: boolean;
@ -144,6 +145,7 @@ export class RedocNormalizedOptions {
menuToggle: boolean; menuToggle: boolean;
jsonSampleExpandLevel: number; jsonSampleExpandLevel: number;
enumSkipQuotes: boolean; enumSkipQuotes: boolean;
hideSchemaTitles: boolean;
/* tslint:disable-next-line */ /* tslint:disable-next-line */
unstable_ignoreMimeParameters: boolean; unstable_ignoreMimeParameters: boolean;
@ -182,6 +184,7 @@ export class RedocNormalizedOptions {
raw.jsonSampleExpandLevel, raw.jsonSampleExpandLevel,
); );
this.enumSkipQuotes = argValueToBoolean(raw.enumSkipQuotes); this.enumSkipQuotes = argValueToBoolean(raw.enumSkipQuotes);
this.hideSchemaTitles = argValueToBoolean(raw.hideSchemaTitles);
this.unstable_ignoreMimeParameters = argValueToBoolean(raw.unstable_ignoreMimeParameters); this.unstable_ignoreMimeParameters = argValueToBoolean(raw.unstable_ignoreMimeParameters);