diff --git a/src/components/ApiInfo/ApiInfo.tsx b/src/components/ApiInfo/ApiInfo.tsx index ae4b4b20..939f8f5f 100644 --- a/src/components/ApiInfo/ApiInfo.tsx +++ b/src/components/ApiInfo/ApiInfo.tsx @@ -70,6 +70,29 @@ export class ApiInfo extends React.Component { const version = (info.version && ({info.version})) || null; + const contributorName = (info['x-contributorDetails'] && info['x-contributorDetails'].name && ( + + Contributed by: {' '} + {info['x-contributorDetails'].name} + + )) || + null; + + const contributorEmail = + (info['x-contributorDetails'] && info['x-contributorDetails'].email && ( + + {info['x-contributorDetails'].email} + + )) || + null; + + const contributorSupportLink = (info['x-contributorDetails'] && info['x-contributorDetails'].supportlink && ( + + Support + + )) || + null; + return (
@@ -99,6 +122,9 @@ export class ApiInfo extends React.Component { )) || null} + + {contributorName} {contributorEmail} {contributorSupportLink} + diff --git a/src/components/Operation/Operation.tsx b/src/components/Operation/Operation.tsx index 57776cf0..11b4198b 100644 --- a/src/components/Operation/Operation.tsx +++ b/src/components/Operation/Operation.tsx @@ -17,7 +17,11 @@ import { RequestSamples } from '../RequestSamples/RequestSamples'; import { ResponsesList } from '../Responses/ResponsesList'; import { ResponseSamples } from '../ResponseSamples/ResponseSamples'; import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement'; - +import { + InfoSpan, + InfoSpanBox, + InfoSpanBoxWrap, +} from './../ApiInfo/styled.elements'; const OperationRow = styled(Row)` backface-visibility: hidden; contain: content; @@ -37,9 +41,31 @@ export class Operation extends React.Component { render() { const { operation } = this.props; - const { name: summary, description, deprecated, externalDocs, isWebhook } = operation; + const { name: summary, description, deprecated, externalDocs, isWebhook, contributorDetails} = operation; const hasDescription = !!(description || externalDocs); + const contributorName = (contributorDetails && contributorDetails['name'] && ( + + Contributed by:{' '} + { contributorDetails['name']} + + )) || + null; + + const contributorEmail = + ( contributorDetails && contributorDetails['email'] && ( + + { contributorDetails['email']} + + )) || + null; + + const contributorSupportLink = ( contributorDetails && contributorDetails['supportlink'] && ( + + Support + + )) || + null; return ( {(options) => ( @@ -50,7 +76,10 @@ export class Operation extends React.Component { {summary} {deprecated && Deprecated } {isWebhook && Webhook } - {options.pathInMiddlePanel && !isWebhook && ( + + {contributorName}{contributorEmail}{contributorSupportLink} + + {options.pathInMiddlePanel && !isWebhook && ( )} {hasDescription && ( diff --git a/src/services/models/Operation.ts b/src/services/models/Operation.ts index d00461a1..1e5e040a 100644 --- a/src/services/models/Operation.ts +++ b/src/services/models/Operation.ts @@ -76,6 +76,7 @@ export class OperationModel implements IMenuItem { extensions: Record; isCallback: boolean; isWebhook: boolean; + contributorDetails: any; constructor( private parser: OpenAPIParser, @@ -99,6 +100,7 @@ export class OperationModel implements IMenuItem { this.path = operationSpec.pathName; this.isCallback = isCallback; this.isWebhook = !!operationSpec.isWebhook; + this.contributorDetails = operationSpec['x-contributorDetails']; this.name = getOperationSummary(operationSpec); diff --git a/src/types/open-api.ts b/src/types/open-api.ts index d55e44b1..24c6f3fa 100644 --- a/src/types/open-api.ts +++ b/src/types/open-api.ts @@ -22,6 +22,7 @@ export interface OpenAPIInfo { termsOfService?: string; contact?: OpenAPIContact; license?: OpenAPILicense; + 'x-contributorDetails'?: OpenAPIContributorDetail; } export interface OpenAPIServer { @@ -47,6 +48,7 @@ export type Referenced = OpenAPIRef | T; export interface OpenAPIPath { summary?: string; + 'x-contributorDetails'?: OpenAPIContributorDetail; description?: string; get?: OpenAPIOperation; put?: OpenAPIOperation; @@ -272,7 +274,11 @@ export interface OpenAPIContact { url?: string; email?: string; } - +export interface OpenAPIContributorDetail { + name?: string; + email?: string; + supportlink?: string; +} export interface OpenAPILicense { name: string; url?: string; diff --git a/src/utils/openapi.ts b/src/utils/openapi.ts index c31e3cd2..d318bb63 100644 --- a/src/utils/openapi.ts +++ b/src/utils/openapi.ts @@ -601,6 +601,7 @@ export function isRedocExtension(key: string): boolean { 'x-examples': true, 'x-ignoredHeaderParameters': true, 'x-logo': true, + 'x-contributorDetails': true, 'x-nullable': true, 'x-servers': true, 'x-tagGroups': true,