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 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 (
|
return (
|
||||||
<Section>
|
<Section>
|
||||||
<Row>
|
<Row>
|
||||||
|
@ -99,6 +122,9 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
|
||||||
</InfoSpanBoxWrap>
|
</InfoSpanBoxWrap>
|
||||||
)) ||
|
)) ||
|
||||||
null}
|
null}
|
||||||
|
<InfoSpanBoxWrap><InfoSpanBox>
|
||||||
|
{contributorName} {contributorEmail} {contributorSupportLink}
|
||||||
|
</InfoSpanBox></InfoSpanBoxWrap>
|
||||||
</StyledMarkdownBlock>
|
</StyledMarkdownBlock>
|
||||||
<Markdown source={store.spec.info.summary} data-role="redoc-summary"/>
|
<Markdown source={store.spec.info.summary} data-role="redoc-summary"/>
|
||||||
<Markdown source={store.spec.info.description} data-role="redoc-description"/>
|
<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 { ResponsesList } from '../Responses/ResponsesList';
|
||||||
import { ResponseSamples } from '../ResponseSamples/ResponseSamples';
|
import { ResponseSamples } from '../ResponseSamples/ResponseSamples';
|
||||||
import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement';
|
import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement';
|
||||||
|
import {
|
||||||
|
InfoSpan,
|
||||||
|
InfoSpanBox,
|
||||||
|
InfoSpanBoxWrap,
|
||||||
|
} from './../ApiInfo/styled.elements';
|
||||||
const OperationRow = styled(Row)`
|
const OperationRow = styled(Row)`
|
||||||
backface-visibility: hidden;
|
backface-visibility: hidden;
|
||||||
contain: content;
|
contain: content;
|
||||||
|
@ -37,9 +41,31 @@ export class Operation extends React.Component<OperationProps> {
|
||||||
render() {
|
render() {
|
||||||
const { operation } = this.props;
|
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 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 (
|
return (
|
||||||
<OptionsContext.Consumer>
|
<OptionsContext.Consumer>
|
||||||
{(options) => (
|
{(options) => (
|
||||||
|
@ -50,7 +76,10 @@ export class Operation extends React.Component<OperationProps> {
|
||||||
{summary} {deprecated && <Badge type="warning"> Deprecated </Badge>}
|
{summary} {deprecated && <Badge type="warning"> Deprecated </Badge>}
|
||||||
{isWebhook && <Badge type="primary"> Webhook </Badge>}
|
{isWebhook && <Badge type="primary"> Webhook </Badge>}
|
||||||
</H2>
|
</H2>
|
||||||
{options.pathInMiddlePanel && !isWebhook && (
|
<InfoSpanBoxWrap><InfoSpanBox>
|
||||||
|
{contributorName}{contributorEmail}{contributorSupportLink}
|
||||||
|
</InfoSpanBox></InfoSpanBoxWrap>
|
||||||
|
{options.pathInMiddlePanel && !isWebhook && (
|
||||||
<Endpoint operation={operation} inverted={true} />
|
<Endpoint operation={operation} inverted={true} />
|
||||||
)}
|
)}
|
||||||
{hasDescription && (
|
{hasDescription && (
|
||||||
|
|
|
@ -76,6 +76,7 @@ export class OperationModel implements IMenuItem {
|
||||||
extensions: Record<string, any>;
|
extensions: Record<string, any>;
|
||||||
isCallback: boolean;
|
isCallback: boolean;
|
||||||
isWebhook: boolean;
|
isWebhook: boolean;
|
||||||
|
contributorDetails: any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private parser: OpenAPIParser,
|
private parser: OpenAPIParser,
|
||||||
|
@ -99,6 +100,7 @@ export class OperationModel implements IMenuItem {
|
||||||
this.path = operationSpec.pathName;
|
this.path = operationSpec.pathName;
|
||||||
this.isCallback = isCallback;
|
this.isCallback = isCallback;
|
||||||
this.isWebhook = !!operationSpec.isWebhook;
|
this.isWebhook = !!operationSpec.isWebhook;
|
||||||
|
this.contributorDetails = operationSpec['x-contributorDetails'];
|
||||||
|
|
||||||
this.name = getOperationSummary(operationSpec);
|
this.name = getOperationSummary(operationSpec);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ export interface OpenAPIInfo {
|
||||||
termsOfService?: string;
|
termsOfService?: string;
|
||||||
contact?: OpenAPIContact;
|
contact?: OpenAPIContact;
|
||||||
license?: OpenAPILicense;
|
license?: OpenAPILicense;
|
||||||
|
'x-contributorDetails'?: OpenAPIContributorDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OpenAPIServer {
|
export interface OpenAPIServer {
|
||||||
|
@ -47,6 +48,7 @@ export type Referenced<T> = OpenAPIRef | T;
|
||||||
|
|
||||||
export interface OpenAPIPath {
|
export interface OpenAPIPath {
|
||||||
summary?: string;
|
summary?: string;
|
||||||
|
'x-contributorDetails'?: OpenAPIContributorDetail;
|
||||||
description?: string;
|
description?: string;
|
||||||
get?: OpenAPIOperation;
|
get?: OpenAPIOperation;
|
||||||
put?: OpenAPIOperation;
|
put?: OpenAPIOperation;
|
||||||
|
@ -272,7 +274,11 @@ export interface OpenAPIContact {
|
||||||
url?: string;
|
url?: string;
|
||||||
email?: string;
|
email?: string;
|
||||||
}
|
}
|
||||||
|
export interface OpenAPIContributorDetail {
|
||||||
|
name?: string;
|
||||||
|
email?: string;
|
||||||
|
supportlink?: string;
|
||||||
|
}
|
||||||
export interface OpenAPILicense {
|
export interface OpenAPILicense {
|
||||||
name: string;
|
name: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
|
|
|
@ -601,6 +601,7 @@ export function isRedocExtension(key: string): boolean {
|
||||||
'x-examples': true,
|
'x-examples': true,
|
||||||
'x-ignoredHeaderParameters': true,
|
'x-ignoredHeaderParameters': true,
|
||||||
'x-logo': true,
|
'x-logo': true,
|
||||||
|
'x-contributorDetails': true,
|
||||||
'x-nullable': true,
|
'x-nullable': true,
|
||||||
'x-servers': true,
|
'x-servers': true,
|
||||||
'x-tagGroups': true,
|
'x-tagGroups': true,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user