mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 13:44:54 +03:00
Add Extension for contributor details.
This commit is contained in:
parent
274b04b432
commit
c9ea62381c
|
@ -70,6 +70,29 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
|
|||
|
||||
const version = (info.version && <span>({info.version})</span>) || null;
|
||||
|
||||
const contributorName = (info['x-contributorDetails'] && info['x-contributorDetails'].name && (
|
||||
<InfoSpan>
|
||||
Contributed by: {' '}
|
||||
{info['x-contributorDetails'].name}
|
||||
</InfoSpan>
|
||||
)) ||
|
||||
null;
|
||||
|
||||
const contributorEmail =
|
||||
(info['x-contributorDetails'] && info['x-contributorDetails'].email && (
|
||||
<InfoSpan>
|
||||
<a href={'mailto:' + info['x-contributorDetails'].email}>{info['x-contributorDetails'].email}</a>
|
||||
</InfoSpan>
|
||||
)) ||
|
||||
null;
|
||||
|
||||
const contributorSupportLink = (info['x-contributorDetails'] && info['x-contributorDetails'].supportlink && (
|
||||
<InfoSpan>
|
||||
<a href={info['x-contributorDetails'].supportlink}>Support</a>
|
||||
</InfoSpan>
|
||||
)) ||
|
||||
null;
|
||||
|
||||
return (
|
||||
<Section>
|
||||
<Row>
|
||||
|
@ -99,6 +122,9 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
|
|||
</InfoSpanBoxWrap>
|
||||
)) ||
|
||||
null}
|
||||
<InfoSpanBoxWrap><InfoSpanBox>
|
||||
{contributorName} {contributorEmail} {contributorSupportLink}
|
||||
</InfoSpanBox></InfoSpanBoxWrap>
|
||||
</StyledMarkdownBlock>
|
||||
<Markdown source={store.spec.info.summary} data-role="redoc-summary"/>
|
||||
<Markdown source={store.spec.info.description} data-role="redoc-description"/>
|
||||
|
|
|
@ -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<OperationProps> {
|
|||
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'] && (
|
||||
<InfoSpan>
|
||||
Contributed by:{' '}
|
||||
{ contributorDetails['name']}
|
||||
</InfoSpan>
|
||||
)) ||
|
||||
null;
|
||||
|
||||
const contributorEmail =
|
||||
( contributorDetails && contributorDetails['email'] && (
|
||||
<InfoSpan>
|
||||
<a href={'mailto:' + contributorDetails['email']}>{ contributorDetails['email']}</a>
|
||||
</InfoSpan>
|
||||
)) ||
|
||||
null;
|
||||
|
||||
const contributorSupportLink = ( contributorDetails && contributorDetails['supportlink'] && (
|
||||
<InfoSpan>
|
||||
<a href={ contributorDetails['supportlink']}>Support</a>
|
||||
</InfoSpan>
|
||||
)) ||
|
||||
null;
|
||||
return (
|
||||
<OptionsContext.Consumer>
|
||||
{(options) => (
|
||||
|
@ -50,6 +76,9 @@ export class Operation extends React.Component<OperationProps> {
|
|||
{summary} {deprecated && <Badge type="warning"> Deprecated </Badge>}
|
||||
{isWebhook && <Badge type="primary"> Webhook </Badge>}
|
||||
</H2>
|
||||
<InfoSpanBoxWrap><InfoSpanBox>
|
||||
{contributorName}{contributorEmail}{contributorSupportLink}
|
||||
</InfoSpanBox></InfoSpanBoxWrap>
|
||||
{options.pathInMiddlePanel && !isWebhook && (
|
||||
<Endpoint operation={operation} inverted={true} />
|
||||
)}
|
||||
|
|
|
@ -76,6 +76,7 @@ export class OperationModel implements IMenuItem {
|
|||
extensions: Record<string, any>;
|
||||
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);
|
||||
|
||||
|
|
|
@ -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<T> = 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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user