Skip to content

Commit

Permalink
use x-displayName in securityDefinitions (#1444)
Browse files Browse the repository at this point in the history
Co-authored-by: elis-k <53352199+elis-k@users.noreply.github.com>
Co-authored-by: AlexVarchuk <olexandr.varchuk@gmail.com>
  • Loading branch information
3 people authored Mar 15, 2022
1 parent 29bbfbd commit ac6fb45
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/SecurityRequirement/SecurityRequirement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SecuritySchemes/SecuritySchemes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion src/services/models/SecurityRequirement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { OpenAPIParser } from '../OpenAPIParser';
export interface SecurityScheme extends OpenAPISecurityScheme {
id: string;
sectionId: string;
displayName: string;
scopes: string[];
}

Expand All @@ -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,
};
})
Expand Down
2 changes: 2 additions & 0 deletions src/services/models/SecuritySchemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class SecuritySchemeModel {
sectionId: string;
type: OpenAPISecurityScheme['type'];
description: string;
displayName: string;
apiKey?: {
name: string;
in: OpenAPISecurityScheme['in'];
Expand All @@ -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 = {
Expand Down

0 comments on commit ac6fb45

Please sign in to comment.