use x-displayName in securityDefinitions (#1444)

Co-authored-by: elis-k <53352199+elis-k@users.noreply.github.com>
Co-authored-by: AlexVarchuk <olexandr.varchuk@gmail.com>
This commit is contained in:
Eli$ 2022-03-15 14:47:22 +01:00 committed by GitHub
parent 29bbfbddbf
commit ac6fb458a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 3 deletions

View File

@ -70,7 +70,7 @@ export class SecurityRequirement extends React.PureComponent<SecurityRequirement
security.schemes.map(scheme => {
return (
<SecurityRequirementAndWrap key={scheme.id}>
<Link to={scheme.sectionId}>{scheme.id}</Link>
<Link to={scheme.sectionId}>{scheme.displayName}</Link>
{scheme.scopes.length > 0 && ' ('}
{scheme.scopes.map(scope => (
<ScopeName key={scope}>{scope}</ScopeName>

View File

@ -73,7 +73,7 @@ export class SecurityDefs extends React.PureComponent<SecurityDefsProps> {
<MiddlePanel>
<H2>
<ShareLink to={scheme.sectionId} />
{scheme.id}
{scheme.displayName}
</H2>
<Markdown source={scheme.description || ''} />
<StyledMarkdownBlock>

View File

@ -5,6 +5,7 @@ import { OpenAPIParser } from '../OpenAPIParser';
export interface SecurityScheme extends OpenAPISecurityScheme {
id: string;
sectionId: string;
displayName: string;
scopes: string[];
}
@ -23,11 +24,13 @@ export class SecurityRequirementModel {
console.warn(`Non existing security scheme referenced: ${id}. Skipping`);
return undefined;
}
const displayName = scheme['x-displayName'] || id;
return {
...scheme,
id,
sectionId: SECURITY_SCHEMES_SECTION_PREFIX + id,
displayName,
scopes,
};
})

View File

@ -7,6 +7,7 @@ export class SecuritySchemeModel {
sectionId: string;
type: OpenAPISecurityScheme['type'];
description: string;
displayName: string;
apiKey?: {
name: string;
in: OpenAPISecurityScheme['in'];
@ -27,6 +28,7 @@ export class SecuritySchemeModel {
this.id = id;
this.sectionId = SECURITY_SCHEMES_SECTION_PREFIX + id;
this.type = info.type;
this.displayName = info['x-displayName'] || id;
this.description = info.description || '';
if (info.type === 'apiKey') {
this.apiKey = {