mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-28 19:43:43 +03:00
parent
c60c6f5891
commit
efd5e09c90
|
@ -17,6 +17,8 @@ export function SecurityHeader(props: SecurityRequirementProps) {
|
||||||
const { security, showSecuritySchemeType, expanded } = props;
|
const { security, showSecuritySchemeType, expanded } = props;
|
||||||
|
|
||||||
const grouping = security.schemes.length > 1;
|
const grouping = security.schemes.length > 1;
|
||||||
|
if (security.schemes.length === 0)
|
||||||
|
return <SecurityRequirementOrWrap expanded={expanded}>None</SecurityRequirementOrWrap>;
|
||||||
return (
|
return (
|
||||||
<SecurityRequirementOrWrap expanded={expanded}>
|
<SecurityRequirementOrWrap expanded={expanded}>
|
||||||
{grouping && '('}
|
{grouping && '('}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {
|
||||||
SecuritySchemesModel,
|
SecuritySchemesModel,
|
||||||
} from '../../services';
|
} from '../../services';
|
||||||
import { StoreProvider } from '../StoreBuilder';
|
import { StoreProvider } from '../StoreBuilder';
|
||||||
|
import { SecurityRequirementModel } from '../../services/models/SecurityRequirement';
|
||||||
import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement';
|
import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement';
|
||||||
import { withTheme } from '../testProviders';
|
import { withTheme } from '../testProviders';
|
||||||
import { SecurityDefs } from '../SecuritySchemes/SecuritySchemes';
|
import { SecurityDefs } from '../SecuritySchemes/SecuritySchemes';
|
||||||
|
@ -50,6 +51,20 @@ describe('SecurityRequirement', () => {
|
||||||
expect(component.html()).toMatchSnapshot();
|
expect(component.html()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should render 'None' when empty object in security open api", () => {
|
||||||
|
const options = new RedocNormalizedOptions({});
|
||||||
|
const parser = new OpenAPIParser(
|
||||||
|
{ openapi: '3.0', info: { title: 'test', version: '0' }, paths: {} },
|
||||||
|
undefined,
|
||||||
|
options,
|
||||||
|
);
|
||||||
|
const securityRequirement = [new SecurityRequirementModel({}, parser)];
|
||||||
|
const component = mount(
|
||||||
|
withTheme(<SecurityRequirements securities={securityRequirement} key={1} />),
|
||||||
|
);
|
||||||
|
expect(component.find('span').at(0).text()).toEqual('None');
|
||||||
|
});
|
||||||
|
|
||||||
it('should hide authDefinition', async () => {
|
it('should hide authDefinition', async () => {
|
||||||
const store = await createStore(simpleSecurityFixture, undefined, {
|
const store = await createStore(simpleSecurityFixture, undefined, {
|
||||||
hideSecuritySection: true,
|
hideSecuritySection: true,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user