mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-06 05:10:20 +03:00
Revert "feat: Webhooks option to reverse readOnly/writeOnly properties #1720"
This reverts commit 7486e70039
.
This commit is contained in:
parent
c04e4035d5
commit
1487b24776
|
@ -1193,7 +1193,7 @@ x-webhooks:
|
||||||
summary: New pet
|
summary: New pet
|
||||||
description: Information about a new pet in the systems
|
description: Information about a new pet in the systems
|
||||||
operationId: newPet
|
operationId: newPet
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
requestBody:
|
requestBody:
|
||||||
content:
|
content:
|
||||||
|
@ -1202,4 +1202,4 @@ x-webhooks:
|
||||||
$ref: "#/components/schemas/Pet"
|
$ref: "#/components/schemas/Pet"
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: Return a 200 status to indicate that the data was received successfully
|
description: Return a 200 status to indicate that the data was received successfully
|
|
@ -11,11 +11,6 @@ const userUrl = window.location.search.match(/url=(.*)$/);
|
||||||
const specUrl =
|
const specUrl =
|
||||||
(userUrl && userUrl[1]) || (swagger ? 'swagger.yaml' : big ? 'big-openapi.json' : 'openapi.yaml');
|
(userUrl && userUrl[1]) || (swagger ? 'swagger.yaml' : big ? 'big-openapi.json' : 'openapi.yaml');
|
||||||
|
|
||||||
const options: RedocRawOptions = {
|
const options: RedocRawOptions = { nativeScrollbars: false, maxDisplayedEnumValues: 3 };
|
||||||
nativeScrollbars: false,
|
|
||||||
maxDisplayedEnumValues: 3,
|
|
||||||
reverseEventsReadOnlyProps: true,
|
|
||||||
reverseEventsWriteOnlyProps: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
render(<RedocStandalone specUrl={specUrl} options={options} />, document.getElementById('example'));
|
render(<RedocStandalone specUrl={specUrl} options={options} />, document.getElementById('example'));
|
||||||
|
|
|
@ -22,4 +22,4 @@
|
||||||
<redoc id="example"></redoc>
|
<redoc id="example"></redoc>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -1,7 +1,7 @@
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { OperationModel, ReverseEventsRWOProps } from '../../services/models';
|
import { OperationModel } from '../../services/models';
|
||||||
import styled from '../../styled-components';
|
import styled from '../../styled-components';
|
||||||
import { Endpoint } from '../Endpoint/Endpoint';
|
import { Endpoint } from '../Endpoint/Endpoint';
|
||||||
import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocumentation';
|
import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocumentation';
|
||||||
|
@ -14,13 +14,12 @@ import { CallbackDetailsWrap } from './styled.elements';
|
||||||
|
|
||||||
export interface CallbackDetailsProps {
|
export interface CallbackDetailsProps {
|
||||||
operation: OperationModel;
|
operation: OperationModel;
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class CallbackDetails extends React.Component<CallbackDetailsProps> {
|
export class CallbackDetails extends React.Component<CallbackDetailsProps> {
|
||||||
render() {
|
render() {
|
||||||
const { operation, reverseEventsReadWriteOnly } = this.props;
|
const { operation } = this.props;
|
||||||
const { description, externalDocs } = operation;
|
const { description, externalDocs } = operation;
|
||||||
const hasDescription = !!(description || externalDocs);
|
const hasDescription = !!(description || externalDocs);
|
||||||
|
|
||||||
|
@ -35,16 +34,8 @@ export class CallbackDetails extends React.Component<CallbackDetailsProps> {
|
||||||
<Endpoint operation={this.props.operation} inverted={true} compact={true} />
|
<Endpoint operation={this.props.operation} inverted={true} compact={true} />
|
||||||
<Extensions extensions={operation.extensions} />
|
<Extensions extensions={operation.extensions} />
|
||||||
<SecurityRequirements securities={operation.security} />
|
<SecurityRequirements securities={operation.security} />
|
||||||
<Parameters
|
<Parameters parameters={operation.parameters} body={operation.requestBody} />
|
||||||
parameters={operation.parameters}
|
<ResponsesList responses={operation.responses} isCallback={operation.isCallback} />
|
||||||
body={operation.requestBody}
|
|
||||||
reverseEventsReadWriteOnly={reverseEventsReadWriteOnly}
|
|
||||||
/>
|
|
||||||
<ResponsesList
|
|
||||||
responses={operation.responses}
|
|
||||||
isCallback={operation.isCallback}
|
|
||||||
reverseEventsReadWriteOnly={reverseEventsReadWriteOnly}
|
|
||||||
/>
|
|
||||||
</CallbackDetailsWrap>
|
</CallbackDetailsWrap>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { OperationModel, ReverseEventsRWOProps } from '../../services/models';
|
import { OperationModel } from '../../services/models';
|
||||||
import { StyledCallbackTitle } from './styled.elements';
|
import { StyledCallbackTitle } from './styled.elements';
|
||||||
import { CallbackDetails } from './CallbackDetails';
|
import { CallbackDetails } from './CallbackDetails';
|
||||||
|
|
||||||
export interface CallbackOperationProps {
|
|
||||||
callbackOperation: OperationModel;
|
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps;
|
|
||||||
}
|
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class CallbackOperation extends React.Component<CallbackOperationProps> {
|
export class CallbackOperation extends React.Component<{ callbackOperation: OperationModel }> {
|
||||||
toggle = () => {
|
toggle = () => {
|
||||||
this.props.callbackOperation.toggle();
|
this.props.callbackOperation.toggle();
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { name, expanded, httpVerb, deprecated } = this.props.callbackOperation;
|
const { name, expanded, httpVerb, deprecated } = this.props.callbackOperation;
|
||||||
const { reverseEventsReadWriteOnly } = this.props;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -29,12 +23,7 @@ export class CallbackOperation extends React.Component<CallbackOperationProps> {
|
||||||
httpVerb={httpVerb}
|
httpVerb={httpVerb}
|
||||||
deprecated={deprecated}
|
deprecated={deprecated}
|
||||||
/>
|
/>
|
||||||
{expanded &&
|
{expanded && <CallbackDetails operation={this.props.callbackOperation} />}
|
||||||
<CallbackDetails
|
|
||||||
operation={this.props.callbackOperation}
|
|
||||||
reverseEventsReadWriteOnly={reverseEventsReadWriteOnly}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { CallbackModel, ReverseEventsRWOProps } from '../../services/models';
|
import { CallbackModel } from '../../services/models';
|
||||||
import styled from '../../styled-components';
|
import styled from '../../styled-components';
|
||||||
import { CallbackOperation } from './CallbackOperation';
|
import { CallbackOperation } from './CallbackOperation';
|
||||||
|
|
||||||
export interface CallbacksListProps {
|
export interface CallbacksListProps {
|
||||||
callbacks: CallbackModel[];
|
callbacks: CallbackModel[];
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CallbacksList extends React.PureComponent<CallbacksListProps> {
|
export class CallbacksList extends React.PureComponent<CallbacksListProps> {
|
||||||
render() {
|
render() {
|
||||||
const { callbacks, reverseEventsReadWriteOnly } = this.props;
|
const { callbacks } = this.props;
|
||||||
|
|
||||||
if (!callbacks || callbacks.length === 0) {
|
if (!callbacks || callbacks.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -23,11 +22,7 @@ export class CallbacksList extends React.PureComponent<CallbacksListProps> {
|
||||||
{callbacks.map(callback => {
|
{callbacks.map(callback => {
|
||||||
return callback.operations.map((operation, index) => {
|
return callback.operations.map((operation, index) => {
|
||||||
return (
|
return (
|
||||||
<CallbackOperation
|
<CallbackOperation key={`${callback.name}_${index}`} callbackOperation={operation} />
|
||||||
key={`${callback.name}_${index}`}
|
|
||||||
callbackOperation={operation}
|
|
||||||
reverseEventsReadWriteOnly={reverseEventsReadWriteOnly}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as React from 'react';
|
||||||
|
|
||||||
import { Badge, DarkRightPanel, H2, MiddlePanel, Row } from '../../common-elements';
|
import { Badge, DarkRightPanel, H2, MiddlePanel, Row } from '../../common-elements';
|
||||||
import { ShareLink } from '../../common-elements/linkify';
|
import { ShareLink } from '../../common-elements/linkify';
|
||||||
import { OperationModel, ReverseEventsRWOProps } from '../../services/models';
|
import { OperationModel } from '../../services/models';
|
||||||
import styled from '../../styled-components';
|
import styled from '../../styled-components';
|
||||||
import { CallbacksList } from '../Callbacks';
|
import { CallbacksList } from '../Callbacks';
|
||||||
import { CallbackSamples } from '../CallbackSamples/CallbackSamples';
|
import { CallbackSamples } from '../CallbackSamples/CallbackSamples';
|
||||||
|
@ -30,14 +30,14 @@ const Description = styled.div`
|
||||||
|
|
||||||
export interface OperationProps {
|
export interface OperationProps {
|
||||||
operation: OperationModel;
|
operation: OperationModel;
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class Operation extends React.Component<OperationProps> {
|
export class Operation extends React.Component<OperationProps> {
|
||||||
render() {
|
render() {
|
||||||
const { operation } = this.props;
|
const { operation } = this.props;
|
||||||
const { name: summary, description, deprecated, externalDocs, isWebhook, reverseEventsReadWriteOnly = {} } = operation;
|
|
||||||
|
const { name: summary, description, deprecated, externalDocs, isWebhook } = operation;
|
||||||
const hasDescription = !!(description || externalDocs);
|
const hasDescription = !!(description || externalDocs);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -61,19 +61,9 @@ export class Operation extends React.Component<OperationProps> {
|
||||||
)}
|
)}
|
||||||
<Extensions extensions={operation.extensions} />
|
<Extensions extensions={operation.extensions} />
|
||||||
<SecurityRequirements securities={operation.security} />
|
<SecurityRequirements securities={operation.security} />
|
||||||
<Parameters
|
<Parameters parameters={operation.parameters} body={operation.requestBody} />
|
||||||
parameters={operation.parameters}
|
<ResponsesList responses={operation.responses} />
|
||||||
body={operation.requestBody}
|
<CallbacksList callbacks={operation.callbacks} />
|
||||||
reverseEventsReadWriteOnly={reverseEventsReadWriteOnly}
|
|
||||||
/>
|
|
||||||
<ResponsesList
|
|
||||||
responses={operation.responses}
|
|
||||||
reverseEventsReadWriteOnly={reverseEventsReadWriteOnly}
|
|
||||||
/>
|
|
||||||
<CallbacksList
|
|
||||||
callbacks={operation.callbacks}
|
|
||||||
reverseEventsReadWriteOnly={reverseEventsReadWriteOnly}
|
|
||||||
/>
|
|
||||||
</MiddlePanel>
|
</MiddlePanel>
|
||||||
<DarkRightPanel>
|
<DarkRightPanel>
|
||||||
{!options.pathInMiddlePanel && !isWebhook && <Endpoint operation={operation} />}
|
{!options.pathInMiddlePanel && !isWebhook && <Endpoint operation={operation} />}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { ParametersGroup } from './ParametersGroup';
|
||||||
|
|
||||||
import { UnderlinedHeader } from '../../common-elements';
|
import { UnderlinedHeader } from '../../common-elements';
|
||||||
|
|
||||||
import { MediaContentModel, ReverseEventsRWOProps } from '../../services';
|
import { MediaContentModel } from '../../services';
|
||||||
import { FieldModel, RequestBodyModel } from '../../services/models';
|
import { FieldModel, RequestBodyModel } from '../../services/models';
|
||||||
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
|
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
|
||||||
import { Schema } from '../Schema';
|
import { Schema } from '../Schema';
|
||||||
|
@ -21,7 +21,6 @@ function safePush(obj, prop, item) {
|
||||||
export interface ParametersProps {
|
export interface ParametersProps {
|
||||||
parameters?: FieldModel[];
|
parameters?: FieldModel[];
|
||||||
body?: RequestBodyModel;
|
body?: RequestBodyModel;
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const PARAM_PLACES = ['path', 'query', 'cookie', 'header'];
|
const PARAM_PLACES = ['path', 'query', 'cookie', 'header'];
|
||||||
|
@ -36,7 +35,7 @@ export class Parameters extends React.PureComponent<ParametersProps> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { body, parameters = [], reverseEventsReadWriteOnly } = this.props;
|
const { body, parameters = [] } = this.props;
|
||||||
if (body === undefined && parameters === undefined) {
|
if (body === undefined && parameters === undefined) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -54,13 +53,7 @@ export class Parameters extends React.PureComponent<ParametersProps> {
|
||||||
{paramsPlaces.map(place => (
|
{paramsPlaces.map(place => (
|
||||||
<ParametersGroup key={place} place={place} parameters={paramsMap[place]} />
|
<ParametersGroup key={place} place={place} parameters={paramsMap[place]} />
|
||||||
))}
|
))}
|
||||||
{bodyContent &&
|
{bodyContent && <BodyContent content={bodyContent} description={bodyDescription} />}
|
||||||
<BodyContent
|
|
||||||
content={bodyContent}
|
|
||||||
description={bodyDescription}
|
|
||||||
reverseEventsReadWriteOnly={reverseEventsReadWriteOnly}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -74,17 +67,15 @@ function DropdownWithinHeader(props) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function BodyContent(props: { content: MediaContentModel; description?: string, reverseEventsReadWriteOnly?: ReverseEventsRWOProps }): JSX.Element {
|
export function BodyContent(props: { content: MediaContentModel; description?: string }): JSX.Element {
|
||||||
const { content, description } = props;
|
const { content, description } = props;
|
||||||
const { reverseEventsReadOnlyProps, reverseEventsWriteOnlyProps } = props.reverseEventsReadWriteOnly || {};
|
|
||||||
const skipReadOnly = !reverseEventsReadOnlyProps;
|
|
||||||
return (
|
return (
|
||||||
<MediaTypesSwitch content={content} renderDropdown={DropdownWithinHeader}>
|
<MediaTypesSwitch content={content} renderDropdown={DropdownWithinHeader}>
|
||||||
{({ schema }) => {
|
{({ schema }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{description !== undefined && <Markdown source={description} />}
|
{description !== undefined && <Markdown source={description} />}
|
||||||
<Schema skipReadOnly={skipReadOnly} skipWriteOnly={reverseEventsWriteOnlyProps} key="schema" schema={schema} />
|
<Schema skipReadOnly={true} key="schema" schema={schema} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -1,25 +1,18 @@
|
||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { ResponseModel, ReverseEventsRWOProps } from '../../services/models';
|
import { ResponseModel } from '../../services/models';
|
||||||
import { ResponseDetails } from './ResponseDetails';
|
import { ResponseDetails } from './ResponseDetails';
|
||||||
import { ResponseDetailsWrap, StyledResponseTitle } from './styled.elements';
|
import { ResponseDetailsWrap, StyledResponseTitle } from './styled.elements';
|
||||||
|
|
||||||
export interface ResponseViewProps {
|
|
||||||
response: ResponseModel;
|
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps;
|
|
||||||
}
|
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ResponseView extends React.Component<ResponseViewProps> {
|
export class ResponseView extends React.Component<{ response: ResponseModel }> {
|
||||||
toggle = () => {
|
toggle = () => {
|
||||||
this.props.response.toggle();
|
this.props.response.toggle();
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { headers, type, summary, description, code, expanded, content } = this.props.response;
|
||||||
reverseEventsReadWriteOnly, response: { headers, type, summary, description, code, expanded, content }
|
|
||||||
} = this.props;
|
|
||||||
const mimes =
|
const mimes =
|
||||||
content === undefined ? [] : content.mediaTypes.filter(mime => mime.schema !== undefined);
|
content === undefined ? [] : content.mediaTypes.filter(mime => mime.schema !== undefined);
|
||||||
|
|
||||||
|
@ -37,10 +30,7 @@ export class ResponseView extends React.Component<ResponseViewProps> {
|
||||||
/>
|
/>
|
||||||
{expanded && !empty && (
|
{expanded && !empty && (
|
||||||
<ResponseDetailsWrap>
|
<ResponseDetailsWrap>
|
||||||
<ResponseDetails
|
<ResponseDetails response={this.props.response} />
|
||||||
response={this.props.response}
|
|
||||||
reverseEventsReadWriteOnly={reverseEventsReadWriteOnly}
|
|
||||||
/>
|
|
||||||
</ResponseDetailsWrap>
|
</ResponseDetailsWrap>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { ResponseModel, ReverseEventsRWOProps } from '../../services/models';
|
import { ResponseModel } from '../../services/models';
|
||||||
|
|
||||||
import { UnderlinedHeader } from '../../common-elements';
|
import { UnderlinedHeader } from '../../common-elements';
|
||||||
import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
|
import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
|
||||||
|
@ -10,22 +10,16 @@ import { Schema } from '../Schema';
|
||||||
import { Markdown } from '../Markdown/Markdown';
|
import { Markdown } from '../Markdown/Markdown';
|
||||||
import { ResponseHeaders } from './ResponseHeaders';
|
import { ResponseHeaders } from './ResponseHeaders';
|
||||||
|
|
||||||
export interface ResponseDetailsProps {
|
export class ResponseDetails extends React.PureComponent<{ response: ResponseModel }> {
|
||||||
response: ResponseModel;
|
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ResponseDetails extends React.PureComponent<ResponseDetailsProps> {
|
|
||||||
render() {
|
render() {
|
||||||
const { reverseEventsReadWriteOnly = {}, response: { description, headers, content } } = this.props;
|
const { description, headers, content } = this.props.response;
|
||||||
const skipWriteOnly = !reverseEventsReadWriteOnly.reverseEventsWriteOnlyProps;
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{description && <Markdown source={description} />}
|
{description && <Markdown source={description} />}
|
||||||
<ResponseHeaders headers={headers} />
|
<ResponseHeaders headers={headers} />
|
||||||
<MediaTypesSwitch content={content} renderDropdown={this.renderDropdown}>
|
<MediaTypesSwitch content={content} renderDropdown={this.renderDropdown}>
|
||||||
{({ schema }) => {
|
{({ schema }) => {
|
||||||
return <Schema skipWriteOnly={skipWriteOnly} key="schema" schema={schema} />;
|
return <Schema skipWriteOnly={true} key="schema" schema={schema} />;
|
||||||
}}
|
}}
|
||||||
</MediaTypesSwitch>
|
</MediaTypesSwitch>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { l } from '../../services/Labels';
|
import { l } from '../../services/Labels';
|
||||||
import { ResponseModel, ReverseEventsRWOProps } from '../../services/models';
|
import { ResponseModel } from '../../services/models';
|
||||||
import styled from '../../styled-components';
|
import styled from '../../styled-components';
|
||||||
import { ResponseView } from './Response';
|
import { ResponseView } from './Response';
|
||||||
|
|
||||||
|
@ -15,12 +15,11 @@ const ResponsesHeader = styled.h3`
|
||||||
export interface ResponseListProps {
|
export interface ResponseListProps {
|
||||||
responses: ResponseModel[];
|
responses: ResponseModel[];
|
||||||
isCallback?: boolean;
|
isCallback?: boolean;
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ResponsesList extends React.PureComponent<ResponseListProps> {
|
export class ResponsesList extends React.PureComponent<ResponseListProps> {
|
||||||
render() {
|
render() {
|
||||||
const { responses, isCallback, reverseEventsReadWriteOnly } = this.props;
|
const { responses, isCallback } = this.props;
|
||||||
|
|
||||||
if (!responses || responses.length === 0) {
|
if (!responses || responses.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -29,11 +28,9 @@ export class ResponsesList extends React.PureComponent<ResponseListProps> {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<ResponsesHeader>{isCallback ? l('callbackResponses') : l('responses')}</ResponsesHeader>
|
<ResponsesHeader>{isCallback ? l('callbackResponses') : l('responses')}</ResponsesHeader>
|
||||||
{responses.map(response => <ResponseView
|
{responses.map(response => {
|
||||||
key={response.code}
|
return <ResponseView key={response.code} response={response} />;
|
||||||
response={response}
|
})}
|
||||||
reverseEventsReadWriteOnly={reverseEventsReadWriteOnly}
|
|
||||||
/>)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,6 @@ export interface RedocRawOptions {
|
||||||
maxDisplayedEnumValues?: number;
|
maxDisplayedEnumValues?: number;
|
||||||
ignoreNamedSchemas?: string[] | string;
|
ignoreNamedSchemas?: string[] | string;
|
||||||
hideSchemaPattern?: boolean;
|
hideSchemaPattern?: boolean;
|
||||||
reverseEventsReadOnlyProps?: boolean;
|
|
||||||
reverseEventsWriteOnlyProps?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
||||||
|
@ -51,7 +49,7 @@ export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean
|
||||||
return defaultValue || false;
|
return defaultValue || false;
|
||||||
}
|
}
|
||||||
if (typeof val === 'string') {
|
if (typeof val === 'string') {
|
||||||
return val !== 'false';
|
return val === 'false' ? false : true;
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -199,9 +197,6 @@ export class RedocNormalizedOptions {
|
||||||
ignoreNamedSchemas: Set<string>;
|
ignoreNamedSchemas: Set<string>;
|
||||||
hideSchemaPattern: boolean;
|
hideSchemaPattern: boolean;
|
||||||
|
|
||||||
reverseEventsReadOnlyProps: boolean;
|
|
||||||
reverseEventsWriteOnlyProps: boolean;
|
|
||||||
|
|
||||||
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
||||||
raw = { ...defaults, ...raw };
|
raw = { ...defaults, ...raw };
|
||||||
const hook = raw.theme && raw.theme.extensionsHook;
|
const hook = raw.theme && raw.theme.extensionsHook;
|
||||||
|
@ -262,7 +257,5 @@ export class RedocNormalizedOptions {
|
||||||
: raw.ignoreNamedSchemas?.split(',').map((s) => s.trim());
|
: raw.ignoreNamedSchemas?.split(',').map((s) => s.trim());
|
||||||
this.ignoreNamedSchemas = new Set(ignoreNamedSchemas);
|
this.ignoreNamedSchemas = new Set(ignoreNamedSchemas);
|
||||||
this.hideSchemaPattern = argValueToBoolean(raw.hideSchemaPattern);
|
this.hideSchemaPattern = argValueToBoolean(raw.hideSchemaPattern);
|
||||||
this.reverseEventsReadOnlyProps = argValueToBoolean(raw.reverseEventsReadOnlyProps);
|
|
||||||
this.reverseEventsWriteOnlyProps = argValueToBoolean(raw.reverseEventsWriteOnlyProps);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import { OpenAPIParser } from '../OpenAPIParser';
|
||||||
import { SchemaModel } from './Schema';
|
import { SchemaModel } from './Schema';
|
||||||
import { ExampleModel } from './Example';
|
import { ExampleModel } from './Example';
|
||||||
import { mapValues } from '../../utils/helpers';
|
import { mapValues } from '../../utils/helpers';
|
||||||
import { ReverseEventsRWOProps } from './Operation';
|
|
||||||
|
|
||||||
const DEFAULT_SERIALIZATION: Record<
|
const DEFAULT_SERIALIZATION: Record<
|
||||||
OpenAPIParameterLocation,
|
OpenAPIParameterLocation,
|
||||||
|
@ -65,7 +64,6 @@ export class FieldModel {
|
||||||
infoOrRef: Referenced<OpenAPIParameter> & { name?: string; kind?: string },
|
infoOrRef: Referenced<OpenAPIParameter> & { name?: string; kind?: string },
|
||||||
pointer: string,
|
pointer: string,
|
||||||
options: RedocNormalizedOptions,
|
options: RedocNormalizedOptions,
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps,
|
|
||||||
) {
|
) {
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
|
|
||||||
|
@ -82,7 +80,7 @@ export class FieldModel {
|
||||||
fieldSchema = info.content[serializationMime] && info.content[serializationMime].schema;
|
fieldSchema = info.content[serializationMime] && info.content[serializationMime].schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.schema = new SchemaModel(parser, fieldSchema || {}, pointer, options, false, reverseEventsReadWriteOnly);
|
this.schema = new SchemaModel(parser, fieldSchema || {}, pointer, options);
|
||||||
this.description =
|
this.description =
|
||||||
info.description === undefined ? this.schema.description || '' : info.description;
|
info.description === undefined ? this.schema.description || '' : info.description;
|
||||||
this.example = info.example || this.schema.example;
|
this.example = info.example || this.schema.example;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import { MediaTypeModel } from './MediaType';
|
||||||
import { mergeSimilarMediaTypes } from '../../utils';
|
import { mergeSimilarMediaTypes } from '../../utils';
|
||||||
import { OpenAPIParser } from '../OpenAPIParser';
|
import { OpenAPIParser } from '../OpenAPIParser';
|
||||||
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
||||||
import { ReverseEventsRWOProps } from './Operation';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MediaContent model ready to be sued by React components
|
* MediaContent model ready to be sued by React components
|
||||||
|
@ -26,7 +25,6 @@ export class MediaContentModel {
|
||||||
info: Record<string, OpenAPIMediaType>,
|
info: Record<string, OpenAPIMediaType>,
|
||||||
public isRequestType: boolean,
|
public isRequestType: boolean,
|
||||||
options: RedocNormalizedOptions,
|
options: RedocNormalizedOptions,
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps,
|
|
||||||
) {
|
) {
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
|
|
||||||
|
@ -37,7 +35,7 @@ export class MediaContentModel {
|
||||||
const mime = info[name];
|
const mime = info[name];
|
||||||
// reset deref cache just in case something is left there
|
// reset deref cache just in case something is left there
|
||||||
parser.resetVisited();
|
parser.resetVisited();
|
||||||
return new MediaTypeModel(parser, name, isRequestType, mime, options, reverseEventsReadWriteOnly);
|
return new MediaTypeModel(parser, name, isRequestType, mime, options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { SchemaModel } from './Schema';
|
||||||
import { isJsonLike, mapValues } from '../../utils';
|
import { isJsonLike, mapValues } from '../../utils';
|
||||||
import { OpenAPIParser } from '../OpenAPIParser';
|
import { OpenAPIParser } from '../OpenAPIParser';
|
||||||
import { ExampleModel } from './Example';
|
import { ExampleModel } from './Example';
|
||||||
import { ReverseEventsRWOProps } from './Operation';
|
|
||||||
|
|
||||||
export class MediaTypeModel {
|
export class MediaTypeModel {
|
||||||
examples?: { [name: string]: ExampleModel };
|
examples?: { [name: string]: ExampleModel };
|
||||||
|
@ -25,11 +24,10 @@ export class MediaTypeModel {
|
||||||
isRequestType: boolean,
|
isRequestType: boolean,
|
||||||
info: OpenAPIMediaType,
|
info: OpenAPIMediaType,
|
||||||
options: RedocNormalizedOptions,
|
options: RedocNormalizedOptions,
|
||||||
reverseEventsReadWriteOnly: ReverseEventsRWOProps = {},
|
|
||||||
) {
|
) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.isRequestType = isRequestType;
|
this.isRequestType = isRequestType;
|
||||||
this.schema = info.schema && new SchemaModel(parser, info.schema, '', options, false, reverseEventsReadWriteOnly);
|
this.schema = info.schema && new SchemaModel(parser, info.schema, '', options);
|
||||||
this.onlyRequiredInSamples = options.onlyRequiredInSamples;
|
this.onlyRequiredInSamples = options.onlyRequiredInSamples;
|
||||||
if (info.examples !== undefined) {
|
if (info.examples !== undefined) {
|
||||||
this.examples = mapValues(
|
this.examples = mapValues(
|
||||||
|
@ -46,16 +44,15 @@ export class MediaTypeModel {
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
} else if (isJsonLike(name)) {
|
} else if (isJsonLike(name)) {
|
||||||
this.generateExample(parser, info, reverseEventsReadWriteOnly);
|
this.generateExample(parser, info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
generateExample(parser: OpenAPIParser, info: OpenAPIMediaType, reverseEventsReadWriteOnly: ReverseEventsRWOProps) {
|
generateExample(parser: OpenAPIParser, info: OpenAPIMediaType) {
|
||||||
const { reverseEventsReadOnlyProps, reverseEventsWriteOnlyProps } = reverseEventsReadWriteOnly;
|
|
||||||
const samplerOptions = {
|
const samplerOptions = {
|
||||||
skipReadOnly: reverseEventsReadOnlyProps ? !this.isRequestType : this.isRequestType,
|
skipReadOnly: this.isRequestType,
|
||||||
skipWriteOnly: reverseEventsWriteOnlyProps ? this.isRequestType : !this.isRequestType,
|
|
||||||
skipNonRequired: this.isRequestType && this.onlyRequiredInSamples,
|
skipNonRequired: this.isRequestType && this.onlyRequiredInSamples,
|
||||||
|
skipWriteOnly: !this.isRequestType,
|
||||||
maxSampleDepth: 10,
|
maxSampleDepth: 10,
|
||||||
};
|
};
|
||||||
if (this.schema && this.schema.oneOf) {
|
if (this.schema && this.schema.oneOf) {
|
||||||
|
|
|
@ -33,11 +33,6 @@ export interface XPayloadSample {
|
||||||
source: string;
|
source: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReverseEventsRWOProps {
|
|
||||||
reverseEventsReadOnlyProps?: boolean;
|
|
||||||
reverseEventsWriteOnlyProps?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isPayloadSample(
|
export function isPayloadSample(
|
||||||
sample: XPayloadSample | OpenAPIXCodeSample,
|
sample: XPayloadSample | OpenAPIXCodeSample,
|
||||||
): sample is XPayloadSample {
|
): sample is XPayloadSample {
|
||||||
|
@ -81,7 +76,6 @@ export class OperationModel implements IMenuItem {
|
||||||
extensions: Record<string, any>;
|
extensions: Record<string, any>;
|
||||||
isCallback: boolean;
|
isCallback: boolean;
|
||||||
isWebhook: boolean;
|
isWebhook: boolean;
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private parser: OpenAPIParser,
|
private parser: OpenAPIParser,
|
||||||
|
@ -106,11 +100,6 @@ export class OperationModel implements IMenuItem {
|
||||||
this.isCallback = isCallback;
|
this.isCallback = isCallback;
|
||||||
this.isWebhook = !!operationSpec.isWebhook;
|
this.isWebhook = !!operationSpec.isWebhook;
|
||||||
|
|
||||||
this.reverseEventsReadWriteOnly = (this.isCallback || this.isWebhook) ? {
|
|
||||||
reverseEventsReadOnlyProps: this.options.reverseEventsReadOnlyProps,
|
|
||||||
reverseEventsWriteOnlyProps: this.options.reverseEventsWriteOnlyProps,
|
|
||||||
} : {};
|
|
||||||
|
|
||||||
this.name = getOperationSummary(operationSpec);
|
this.name = getOperationSummary(operationSpec);
|
||||||
|
|
||||||
if (this.isCallback) {
|
if (this.isCallback) {
|
||||||
|
@ -183,11 +172,7 @@ export class OperationModel implements IMenuItem {
|
||||||
get requestBody() {
|
get requestBody() {
|
||||||
return (
|
return (
|
||||||
this.operationSpec.requestBody &&
|
this.operationSpec.requestBody &&
|
||||||
new RequestBodyModel(this.parser,
|
new RequestBodyModel(this.parser, this.operationSpec.requestBody, this.options)
|
||||||
this.operationSpec.requestBody,
|
|
||||||
this.options,
|
|
||||||
this.reverseEventsReadWriteOnly,
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,13 +212,7 @@ export class OperationModel implements IMenuItem {
|
||||||
this.operationSpec.pathParameters,
|
this.operationSpec.pathParameters,
|
||||||
this.operationSpec.parameters,
|
this.operationSpec.parameters,
|
||||||
// TODO: fix pointer
|
// TODO: fix pointer
|
||||||
).map((paramOrRef) => new FieldModel(
|
).map((paramOrRef) => new FieldModel(this.parser, paramOrRef, this.pointer, this.options));
|
||||||
this.parser,
|
|
||||||
paramOrRef,
|
|
||||||
this.pointer,
|
|
||||||
this.options,
|
|
||||||
this.reverseEventsReadWriteOnly,
|
|
||||||
));
|
|
||||||
|
|
||||||
if (this.options.sortPropsAlphabetically) {
|
if (this.options.sortPropsAlphabetically) {
|
||||||
return sortByField(_parameters, 'name');
|
return sortByField(_parameters, 'name');
|
||||||
|
@ -267,7 +246,6 @@ export class OperationModel implements IMenuItem {
|
||||||
hasSuccessResponses,
|
hasSuccessResponses,
|
||||||
this.operationSpec.responses[code],
|
this.operationSpec.responses[code],
|
||||||
this.options,
|
this.options,
|
||||||
this.reverseEventsReadWriteOnly,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { OpenAPIRequestBody, Referenced } from '../../types';
|
||||||
import { OpenAPIParser } from '../OpenAPIParser';
|
import { OpenAPIParser } from '../OpenAPIParser';
|
||||||
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
||||||
import { MediaContentModel } from './MediaContent';
|
import { MediaContentModel } from './MediaContent';
|
||||||
import { ReverseEventsRWOProps } from './Operation';
|
|
||||||
|
|
||||||
export class RequestBodyModel {
|
export class RequestBodyModel {
|
||||||
description: string;
|
description: string;
|
||||||
|
@ -14,14 +13,13 @@ export class RequestBodyModel {
|
||||||
parser: OpenAPIParser,
|
parser: OpenAPIParser,
|
||||||
infoOrRef: Referenced<OpenAPIRequestBody>,
|
infoOrRef: Referenced<OpenAPIRequestBody>,
|
||||||
options: RedocNormalizedOptions,
|
options: RedocNormalizedOptions,
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps,
|
|
||||||
) {
|
) {
|
||||||
const info = parser.deref(infoOrRef);
|
const info = parser.deref(infoOrRef);
|
||||||
this.description = info.description || '';
|
this.description = info.description || '';
|
||||||
this.required = !!info.required;
|
this.required = !!info.required;
|
||||||
parser.exitRef(infoOrRef);
|
parser.exitRef(infoOrRef);
|
||||||
if (info.content !== undefined) {
|
if (info.content !== undefined) {
|
||||||
this.content = new MediaContentModel(parser, info.content, true, options, reverseEventsReadWriteOnly);
|
this.content = new MediaContentModel(parser, info.content, true, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { OpenAPIParser } from '../OpenAPIParser';
|
||||||
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
||||||
import { FieldModel } from './Field';
|
import { FieldModel } from './Field';
|
||||||
import { MediaContentModel } from './MediaContent';
|
import { MediaContentModel } from './MediaContent';
|
||||||
import { ReverseEventsRWOProps } from './Operation';
|
|
||||||
|
|
||||||
export class ResponseModel {
|
export class ResponseModel {
|
||||||
@observable
|
@observable
|
||||||
|
@ -26,7 +25,6 @@ export class ResponseModel {
|
||||||
defaultAsError: boolean,
|
defaultAsError: boolean,
|
||||||
infoOrRef: Referenced<OpenAPIResponse>,
|
infoOrRef: Referenced<OpenAPIResponse>,
|
||||||
options: RedocNormalizedOptions,
|
options: RedocNormalizedOptions,
|
||||||
reverseEventsReadWriteOnly?: ReverseEventsRWOProps,
|
|
||||||
) {
|
) {
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
|
|
||||||
|
@ -36,7 +34,7 @@ export class ResponseModel {
|
||||||
parser.exitRef(infoOrRef);
|
parser.exitRef(infoOrRef);
|
||||||
this.code = code;
|
this.code = code;
|
||||||
if (info.content !== undefined) {
|
if (info.content !== undefined) {
|
||||||
this.content = new MediaContentModel(parser, info.content, false, options, reverseEventsReadWriteOnly);
|
this.content = new MediaContentModel(parser, info.content, false, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info['x-summary'] !== undefined) {
|
if (info['x-summary'] !== undefined) {
|
||||||
|
@ -53,7 +51,7 @@ export class ResponseModel {
|
||||||
if (headers !== undefined) {
|
if (headers !== undefined) {
|
||||||
this.headers = Object.keys(headers).map(name => {
|
this.headers = Object.keys(headers).map(name => {
|
||||||
const header = headers[name];
|
const header = headers[name];
|
||||||
return new FieldModel(parser, { ...header, name }, '', options, reverseEventsReadWriteOnly);
|
return new FieldModel(parser, { ...header, name }, '', options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { OpenAPIParser } from '../OpenAPIParser';
|
||||||
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
||||||
import { FieldModel } from './Field';
|
import { FieldModel } from './Field';
|
||||||
|
|
||||||
import { MergedOpenAPISchema, ReverseEventsRWOProps } from '../';
|
import { MergedOpenAPISchema } from '../';
|
||||||
import {
|
import {
|
||||||
detectType,
|
detectType,
|
||||||
extractExtensions,
|
extractExtensions,
|
||||||
|
@ -74,7 +74,6 @@ export class SchemaModel {
|
||||||
pointer: string,
|
pointer: string,
|
||||||
private options: RedocNormalizedOptions,
|
private options: RedocNormalizedOptions,
|
||||||
isChild: boolean = false,
|
isChild: boolean = false,
|
||||||
reverseEventsReadWriteOnly: ReverseEventsRWOProps = {},
|
|
||||||
) {
|
) {
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ export class SchemaModel {
|
||||||
this.rawSchema = parser.deref(schemaOrRef, false, true);
|
this.rawSchema = parser.deref(schemaOrRef, false, true);
|
||||||
this.schema = parser.mergeAllOf(this.rawSchema, this.pointer, isChild);
|
this.schema = parser.mergeAllOf(this.rawSchema, this.pointer, isChild);
|
||||||
|
|
||||||
this.init(parser, isChild, reverseEventsReadWriteOnly);
|
this.init(parser, isChild);
|
||||||
|
|
||||||
parser.exitRef(schemaOrRef);
|
parser.exitRef(schemaOrRef);
|
||||||
parser.exitParents(this.schema);
|
parser.exitParents(this.schema);
|
||||||
|
@ -105,7 +104,7 @@ export class SchemaModel {
|
||||||
return this.type === type || (Array.isArray(this.type) && this.type.includes(type));
|
return this.type === type || (Array.isArray(this.type) && this.type.includes(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
init(parser: OpenAPIParser, isChild: boolean, reverseEventsReadWriteOnly: ReverseEventsRWOProps) {
|
init(parser: OpenAPIParser, isChild: boolean) {
|
||||||
const schema = this.schema;
|
const schema = this.schema;
|
||||||
this.isCircular = schema['x-circular-ref'];
|
this.isCircular = schema['x-circular-ref'];
|
||||||
|
|
||||||
|
@ -147,7 +146,7 @@ export class SchemaModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isChild && getDiscriminator(schema) !== undefined) {
|
if (!isChild && getDiscriminator(schema) !== undefined) {
|
||||||
this.initDiscriminator(schema, parser, reverseEventsReadWriteOnly);
|
this.initDiscriminator(schema, parser);
|
||||||
return;
|
return;
|
||||||
} else if (
|
} else if (
|
||||||
isChild &&
|
isChild &&
|
||||||
|
@ -159,7 +158,7 @@ export class SchemaModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schema.oneOf !== undefined) {
|
if (schema.oneOf !== undefined) {
|
||||||
this.initOneOf(schema.oneOf, parser, reverseEventsReadWriteOnly);
|
this.initOneOf(schema.oneOf, parser);
|
||||||
this.oneOfType = 'One of';
|
this.oneOfType = 'One of';
|
||||||
if (schema.anyOf !== undefined) {
|
if (schema.anyOf !== undefined) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
@ -170,17 +169,15 @@ export class SchemaModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schema.anyOf !== undefined) {
|
if (schema.anyOf !== undefined) {
|
||||||
this.initOneOf(schema.anyOf, parser, reverseEventsReadWriteOnly);
|
this.initOneOf(schema.anyOf, parser);
|
||||||
this.oneOfType = 'Any of';
|
this.oneOfType = 'Any of';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasType('object')) {
|
if (this.hasType('object')) {
|
||||||
this.fields = buildFields(parser, schema, this.pointer, this.options, reverseEventsReadWriteOnly);
|
this.fields = buildFields(parser, schema, this.pointer, this.options);
|
||||||
} else if (this.hasType('array') && schema.items) {
|
} else if (this.hasType('array') && schema.items) {
|
||||||
this.items = new SchemaModel(
|
this.items = new SchemaModel(parser, schema.items, this.pointer + '/items', this.options);
|
||||||
parser, schema.items, this.pointer + '/items', this.options, false, reverseEventsReadWriteOnly
|
|
||||||
);
|
|
||||||
this.displayType = pluralizeType(this.items.displayType);
|
this.displayType = pluralizeType(this.items.displayType);
|
||||||
this.displayFormat = this.items.format;
|
this.displayFormat = this.items.format;
|
||||||
this.typePrefix = this.items.typePrefix + l('arrayOf');
|
this.typePrefix = this.items.typePrefix + l('arrayOf');
|
||||||
|
@ -204,7 +201,7 @@ export class SchemaModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private initOneOf(oneOf: OpenAPISchema[], parser: OpenAPIParser, reverseEventsReadWriteOnly: ReverseEventsRWOProps) {
|
private initOneOf(oneOf: OpenAPISchema[], parser: OpenAPIParser) {
|
||||||
this.oneOf = oneOf!.map((variant, idx) => {
|
this.oneOf = oneOf!.map((variant, idx) => {
|
||||||
const derefVariant = parser.deref(variant, false, true);
|
const derefVariant = parser.deref(variant, false, true);
|
||||||
|
|
||||||
|
@ -227,8 +224,6 @@ export class SchemaModel {
|
||||||
} as OpenAPISchema,
|
} as OpenAPISchema,
|
||||||
this.pointer + '/oneOf/' + idx,
|
this.pointer + '/oneOf/' + idx,
|
||||||
this.options,
|
this.options,
|
||||||
false,
|
|
||||||
reverseEventsReadWriteOnly,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
parser.exitRef(variant);
|
parser.exitRef(variant);
|
||||||
|
@ -262,7 +257,6 @@ export class SchemaModel {
|
||||||
parentRefs?: string[];
|
parentRefs?: string[];
|
||||||
},
|
},
|
||||||
parser: OpenAPIParser,
|
parser: OpenAPIParser,
|
||||||
reverseEventsReadWriteOnly,
|
|
||||||
) {
|
) {
|
||||||
const discriminator = getDiscriminator(schema)!;
|
const discriminator = getDiscriminator(schema)!;
|
||||||
this.discriminatorProp = discriminator.propertyName;
|
this.discriminatorProp = discriminator.propertyName;
|
||||||
|
@ -350,7 +344,7 @@ export class SchemaModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.oneOf = refs.map(({ $ref, name }) => {
|
this.oneOf = refs.map(({ $ref, name }) => {
|
||||||
const innerSchema = new SchemaModel(parser, parser.byRef($ref)!, $ref, this.options, true, reverseEventsReadWriteOnly);
|
const innerSchema = new SchemaModel(parser, parser.byRef($ref)!, $ref, this.options, true);
|
||||||
innerSchema.title = name;
|
innerSchema.title = name;
|
||||||
return innerSchema;
|
return innerSchema;
|
||||||
});
|
});
|
||||||
|
@ -362,7 +356,6 @@ function buildFields(
|
||||||
schema: OpenAPISchema,
|
schema: OpenAPISchema,
|
||||||
$ref: string,
|
$ref: string,
|
||||||
options: RedocNormalizedOptions,
|
options: RedocNormalizedOptions,
|
||||||
reverseEventsReadWriteOnly: ReverseEventsRWOProps,
|
|
||||||
): FieldModel[] {
|
): FieldModel[] {
|
||||||
const props = schema.properties || {};
|
const props = schema.properties || {};
|
||||||
const additionalProps = schema.additionalProperties;
|
const additionalProps = schema.additionalProperties;
|
||||||
|
@ -392,7 +385,6 @@ function buildFields(
|
||||||
},
|
},
|
||||||
$ref + '/properties/' + fieldName,
|
$ref + '/properties/' + fieldName,
|
||||||
options,
|
options,
|
||||||
reverseEventsReadWriteOnly,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -419,7 +411,6 @@ function buildFields(
|
||||||
},
|
},
|
||||||
$ref + '/additionalProperties',
|
$ref + '/additionalProperties',
|
||||||
options,
|
options,
|
||||||
reverseEventsReadWriteOnly,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user