mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-08 06:04:56 +03:00
Move displaying Endpoint info to Callback section
This commit is contained in:
parent
7adcdc015d
commit
4f49b28d84
|
@ -4,7 +4,6 @@ import * as React from 'react';
|
||||||
import { RightPanelHeader, Tab, TabList, TabPanel, Tabs } from '../../common-elements';
|
import { RightPanelHeader, Tab, TabList, TabPanel, Tabs } from '../../common-elements';
|
||||||
import { isPayloadSample, RedocNormalizedOptions } from '../../services';
|
import { isPayloadSample, RedocNormalizedOptions } from '../../services';
|
||||||
import { CallbackModel } from '../../services/models';
|
import { CallbackModel } from '../../services/models';
|
||||||
import { Endpoint } from '../Endpoint/Endpoint';
|
|
||||||
import { OptionsContext } from '../OptionsProvider';
|
import { OptionsContext } from '../OptionsProvider';
|
||||||
import { PayloadSamples } from '../PayloadSamples/PayloadSamples';
|
import { PayloadSamples } from '../PayloadSamples/PayloadSamples';
|
||||||
import { SourceCodeWithCopy } from '../SourceCode/SourceCode';
|
import { SourceCodeWithCopy } from '../SourceCode/SourceCode';
|
||||||
|
@ -57,7 +56,6 @@ export class CallbackSamples extends React.Component<CallbackSamplesProps> {
|
||||||
<TabPanel key={sample.lang + '_' + (sample.label || '')}>
|
<TabPanel key={sample.lang + '_' + (sample.label || '')}>
|
||||||
{isPayloadSample(sample) ? (
|
{isPayloadSample(sample) ? (
|
||||||
<div>
|
<div>
|
||||||
<Endpoint operation={operation} inverted={false} />
|
|
||||||
<PayloadSamples content={sample.requestBodyContent} />
|
<PayloadSamples content={sample.requestBodyContent} />
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -15,7 +15,7 @@ export class CallbackView extends React.Component<{ callbackOperation: Operation
|
||||||
const { name, description, expanded } = this.props.callbackOperation;
|
const { name, description, expanded } = this.props.callbackOperation;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<>
|
||||||
<StyledCallbackTitle
|
<StyledCallbackTitle
|
||||||
onClick={this.toggle}
|
onClick={this.toggle}
|
||||||
name={name}
|
name={name}
|
||||||
|
@ -27,7 +27,7 @@ export class CallbackView extends React.Component<{ callbackOperation: Operation
|
||||||
<CallbackDetails callbackOperation={this.props.callbackOperation} />
|
<CallbackDetails callbackOperation={this.props.callbackOperation} />
|
||||||
</CallbackDetailsWrap>
|
</CallbackDetailsWrap>
|
||||||
)}
|
)}
|
||||||
</div>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,15 @@ import * as React from 'react';
|
||||||
|
|
||||||
import { OperationModel } from '../../services/models';
|
import { OperationModel } from '../../services/models';
|
||||||
import { OperationItem } from '../ContentItems/ContentItems';
|
import { OperationItem } from '../ContentItems/ContentItems';
|
||||||
|
import { Endpoint } from '../Endpoint/Endpoint';
|
||||||
|
|
||||||
export class CallbackDetails extends React.PureComponent<{ callbackOperation: OperationModel }> {
|
export class CallbackDetails extends React.PureComponent<{ callbackOperation: OperationModel }> {
|
||||||
render() {
|
render() {
|
||||||
return <OperationItem item={this.props.callbackOperation} />;
|
return (
|
||||||
|
<div>
|
||||||
|
<Endpoint operation={this.props.callbackOperation} inverted={true} />
|
||||||
|
<OperationItem item={this.props.callbackOperation} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,5 +11,8 @@ export const StyledCallbackTitle = styled(CallbackTitle)`
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const CallbackDetailsWrap = styled.div`
|
export const CallbackDetailsWrap = styled.div`
|
||||||
padding: 10px;
|
padding: 10px 25px;
|
||||||
|
background-color: #fafafa;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
margin-top: 5px;
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -108,6 +108,10 @@ export class OperationModel implements IMenuItem {
|
||||||
this.path = operationSpec.pathName;
|
this.path = operationSpec.pathName;
|
||||||
this.isCallback = isCallback;
|
this.isCallback = isCallback;
|
||||||
|
|
||||||
|
const pathInfo = parser.byRef<OpenAPIPath>(
|
||||||
|
JsonPointer.compile(['paths', operationSpec.pathName]),
|
||||||
|
);
|
||||||
|
|
||||||
if (this.isCallback) {
|
if (this.isCallback) {
|
||||||
// NOTE: Use callback's event name as the view label, not the operationID.
|
// NOTE: Use callback's event name as the view label, not the operationID.
|
||||||
this.name = callbackEventName || getOperationSummary(operationSpec);
|
this.name = callbackEventName || getOperationSummary(operationSpec);
|
||||||
|
@ -116,24 +120,24 @@ export class OperationModel implements IMenuItem {
|
||||||
this.security = (operationSpec.security || []).map(
|
this.security = (operationSpec.security || []).map(
|
||||||
security => new SecurityRequirementModel(security, parser),
|
security => new SecurityRequirementModel(security, parser),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO: update getting pathInfo
|
||||||
|
this.servers = normalizeServers(
|
||||||
|
'',
|
||||||
|
operationSpec.servers || (pathInfo && pathInfo.servers) || [],
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.name = getOperationSummary(operationSpec);
|
this.name = getOperationSummary(operationSpec);
|
||||||
this.security = (operationSpec.security || parser.spec.security || []).map(
|
this.security = (operationSpec.security || parser.spec.security || []).map(
|
||||||
security => new SecurityRequirementModel(security, parser),
|
security => new SecurityRequirementModel(security, parser),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.servers = normalizeServers(
|
||||||
|
parser.specUrl,
|
||||||
|
operationSpec.servers || (pathInfo && pathInfo.servers) || parser.spec.servers || [],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const pathInfo = parser.byRef<OpenAPIPath>(
|
|
||||||
JsonPointer.compile(['paths', operationSpec.pathName]),
|
|
||||||
);
|
|
||||||
|
|
||||||
// NOTE: Callbacks by default will inherit the specification's global `servers` definition.
|
|
||||||
// In many cases, this may be undesirable. Override individually in the specification to remedy this.
|
|
||||||
this.servers = normalizeServers(
|
|
||||||
parser.specUrl,
|
|
||||||
operationSpec.servers || (pathInfo && pathInfo.servers) || parser.spec.servers || [],
|
|
||||||
);
|
|
||||||
|
|
||||||
if (options.showExtensions) {
|
if (options.showExtensions) {
|
||||||
this.extensions = extractExtensions(operationSpec, options.showExtensions);
|
this.extensions = extractExtensions(operationSpec, options.showExtensions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,7 @@ const {
|
||||||
createGlobalStyle,
|
createGlobalStyle,
|
||||||
keyframes,
|
keyframes,
|
||||||
ThemeProvider,
|
ThemeProvider,
|
||||||
} = (styledComponents as any) as styledComponents.ThemedStyledComponentsModule<
|
} = styledComponents as styledComponents.ThemedStyledComponentsModule<ResolvedThemeInterface>;
|
||||||
ResolvedThemeInterface
|
|
||||||
>;
|
|
||||||
|
|
||||||
export const media = {
|
export const media = {
|
||||||
lessThan(breakpoint, print?: boolean) {
|
lessThan(breakpoint, print?: boolean) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user