mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 00:26:34 +03:00
feat: add hideSecuritySection option allowing to disable the Security panel (#2027)
This commit is contained in:
parent
a863302cc8
commit
49cc11d917
|
@ -27,7 +27,7 @@ export function SecurityRequirements(props: SecurityRequirementsProps) {
|
|||
|
||||
const { securities } = props;
|
||||
|
||||
if (!securities?.length) {
|
||||
if (!securities?.length || store?.options.hideSecuritySection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,4 +49,24 @@ describe('SecurityRequirement', () => {
|
|||
);
|
||||
expect(component.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should hide authDefinition', async () => {
|
||||
const store = await createStore(simpleSecurityFixture, undefined, {
|
||||
hideSecuritySection: true,
|
||||
});
|
||||
|
||||
store.spec.contentItems.forEach((item: OperationModel) => {
|
||||
if (item.security) {
|
||||
const component = mount(
|
||||
withTheme(
|
||||
<StoreProvider value={store}>
|
||||
<SecurityRequirements securities={item.security} />,
|
||||
</StoreProvider>,
|
||||
),
|
||||
);
|
||||
expect(component.html().includes('Authorizations')).toBe(false);
|
||||
expect(component.html().includes('svg')).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -89,6 +89,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
"hideSecuritySection": false,
|
||||
"hideSingleRequestSampleTab": false,
|
||||
"ignoreNamedSchemas": Set {},
|
||||
"jsonSampleExpandLevel": 2,
|
||||
|
@ -346,6 +347,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
"hideSecuritySection": false,
|
||||
"hideSingleRequestSampleTab": false,
|
||||
"ignoreNamedSchemas": Set {},
|
||||
"jsonSampleExpandLevel": 2,
|
||||
|
@ -578,6 +580,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
"hideSecuritySection": false,
|
||||
"hideSingleRequestSampleTab": false,
|
||||
"ignoreNamedSchemas": Set {},
|
||||
"jsonSampleExpandLevel": 2,
|
||||
|
@ -877,6 +880,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
"hideSecuritySection": false,
|
||||
"hideSingleRequestSampleTab": false,
|
||||
"ignoreNamedSchemas": Set {},
|
||||
"jsonSampleExpandLevel": 2,
|
||||
|
@ -1134,6 +1138,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
"hideSecuritySection": false,
|
||||
"hideSingleRequestSampleTab": false,
|
||||
"ignoreNamedSchemas": Set {},
|
||||
"jsonSampleExpandLevel": 2,
|
||||
|
@ -1366,6 +1371,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
"hideSecuritySection": false,
|
||||
"hideSingleRequestSampleTab": false,
|
||||
"ignoreNamedSchemas": Set {},
|
||||
"jsonSampleExpandLevel": 2,
|
||||
|
@ -1621,6 +1627,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
"hideSecuritySection": false,
|
||||
"hideSingleRequestSampleTab": false,
|
||||
"ignoreNamedSchemas": Set {},
|
||||
"jsonSampleExpandLevel": 2,
|
||||
|
@ -1917,6 +1924,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
"hideSecuritySection": false,
|
||||
"hideSingleRequestSampleTab": false,
|
||||
"ignoreNamedSchemas": Set {},
|
||||
"jsonSampleExpandLevel": 2,
|
||||
|
@ -2174,6 +2182,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
"hideSecuritySection": false,
|
||||
"hideSingleRequestSampleTab": false,
|
||||
"ignoreNamedSchemas": Set {},
|
||||
"jsonSampleExpandLevel": 2,
|
||||
|
@ -2406,6 +2415,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
|||
"hideHostname": false,
|
||||
"hideSchemaPattern": false,
|
||||
"hideSchemaTitles": false,
|
||||
"hideSecuritySection": false,
|
||||
"hideSingleRequestSampleTab": false,
|
||||
"ignoreNamedSchemas": Set {},
|
||||
"jsonSampleExpandLevel": 2,
|
||||
|
|
|
@ -42,6 +42,7 @@ export interface RedocRawOptions {
|
|||
schemaExpansionLevel?: number | string | 'all';
|
||||
showObjectSchemaExamples?: boolean | string;
|
||||
showSecuritySchemeType?: boolean;
|
||||
hideSecuritySection?: boolean;
|
||||
|
||||
unstable_ignoreMimeParameters?: boolean;
|
||||
|
||||
|
@ -245,6 +246,7 @@ export class RedocNormalizedOptions {
|
|||
schemaExpansionLevel: number;
|
||||
showObjectSchemaExamples: boolean;
|
||||
showSecuritySchemeType?: boolean;
|
||||
hideSecuritySection?: boolean;
|
||||
|
||||
/* tslint:disable-next-line */
|
||||
unstable_ignoreMimeParameters: boolean;
|
||||
|
@ -317,6 +319,7 @@ export class RedocNormalizedOptions {
|
|||
this.schemaExpansionLevel = argValueToExpandLevel(raw.schemaExpansionLevel);
|
||||
this.showObjectSchemaExamples = argValueToBoolean(raw.showObjectSchemaExamples);
|
||||
this.showSecuritySchemeType = argValueToBoolean(raw.showSecuritySchemeType);
|
||||
this.hideSecuritySection = argValueToBoolean(raw.hideSecuritySection);
|
||||
|
||||
this.unstable_ignoreMimeParameters = argValueToBoolean(raw.unstable_ignoreMimeParameters);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user