diff --git a/src/components/CallbackSamples/CallbackSamples.tsx b/src/components/CallbackSamples/CallbackSamples.tsx index 0edfca78..26892b68 100644 --- a/src/components/CallbackSamples/CallbackSamples.tsx +++ b/src/components/CallbackSamples/CallbackSamples.tsx @@ -1,13 +1,13 @@ import { observer } from 'mobx-react'; import * as React from 'react'; -import { isPayloadSample, RedocNormalizedOptions } from '../../services'; -import { PayloadSamples } from '../PayloadSamples/PayloadSamples'; -import { SourceCodeWithCopy } from '../SourceCode/SourceCode'; import { RightPanelHeader, Tab, TabList, TabPanel, Tabs } from '../../common-elements'; -import { OptionsContext } from '../OptionsProvider'; +import { isPayloadSample, RedocNormalizedOptions } from '../../services'; import { CallbackModel } from '../../services/models'; import { Endpoint } from '../Endpoint/Endpoint'; +import { OptionsContext } from '../OptionsProvider'; +import { PayloadSamples } from '../PayloadSamples/PayloadSamples'; +import { SourceCodeWithCopy } from '../SourceCode/SourceCode'; export interface CallbackSamplesProps { callbacks: CallbackModel[]; diff --git a/src/components/Callbacks/Callback.tsx b/src/components/Callbacks/Callback.tsx index 761f3504..97160a55 100644 --- a/src/components/Callbacks/Callback.tsx +++ b/src/components/Callbacks/Callback.tsx @@ -1,8 +1,9 @@ import { observer } from 'mobx-react'; import * as React from 'react'; + import { OperationModel } from '../../services/models'; -import { CallbackDetails } from './CallbackDetails'; import { CallbackDetailsWrap, StyledCallbackTitle } from '../Callbacks/styled.elements'; +import { CallbackDetails } from './CallbackDetails'; @observer export class CallbackView extends React.Component<{ callbackOperation: OperationModel }> { diff --git a/src/components/Callbacks/CallbackDetails.tsx b/src/components/Callbacks/CallbackDetails.tsx index e84bc091..757926d0 100644 --- a/src/components/Callbacks/CallbackDetails.tsx +++ b/src/components/Callbacks/CallbackDetails.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; + import { OperationModel } from '../../services/models'; import { OperationItem } from '../ContentItems/ContentItems'; diff --git a/src/components/Callbacks/CallbacksList.tsx b/src/components/Callbacks/CallbacksList.tsx index ce108ccb..82597898 100644 --- a/src/components/Callbacks/CallbacksList.tsx +++ b/src/components/Callbacks/CallbacksList.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; + import { CallbackModel } from '../../services/models'; import styled from '../../styled-components'; import { CallbackView } from './Callback'; diff --git a/src/components/Operation/Operation.tsx b/src/components/Operation/Operation.tsx index aff0cb0b..402affd0 100644 --- a/src/components/Operation/Operation.tsx +++ b/src/components/Operation/Operation.tsx @@ -1,26 +1,22 @@ -import * as React from 'react'; -import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement'; - import { observer } from 'mobx-react'; +import * as React from 'react'; import { Badge, DarkRightPanel, H2, MiddlePanel, Row } from '../../common-elements'; - -import { OptionsContext } from '../OptionsProvider'; - import { ShareLink } from '../../common-elements/linkify'; +import { OperationModel as OperationType } from '../../services/models'; +import styled from '../../styled-components'; +import { CallbacksList } from '../Callbacks'; +import { CallbackSamples } from '../CallbackSamples/CallbackSamples'; import { Endpoint } from '../Endpoint/Endpoint'; import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocumentation'; +import { Extensions } from '../Fields/Extensions'; import { Markdown } from '../Markdown/Markdown'; +import { OptionsContext } from '../OptionsProvider'; import { Parameters } from '../Parameters/Parameters'; import { RequestSamples } from '../RequestSamples/RequestSamples'; import { ResponsesList } from '../Responses/ResponsesList'; import { ResponseSamples } from '../ResponseSamples/ResponseSamples'; -import { CallbacksList } from '../Callbacks'; -import { CallbackSamples } from '../CallbackSamples/CallbackSamples'; - -import { OperationModel as OperationType } from '../../services/models'; -import styled from '../../styled-components'; -import { Extensions } from '../Fields/Extensions'; +import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement'; const CallbackMiddlePanel = styled(MiddlePanel)` width: 100%; diff --git a/src/components/__tests__/Callbacks.test.tsx b/src/components/__tests__/Callbacks.test.tsx index d33705d8..0f8cb390 100644 --- a/src/components/__tests__/Callbacks.test.tsx +++ b/src/components/__tests__/Callbacks.test.tsx @@ -4,9 +4,8 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { OpenAPIParser } from '../../services'; -import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions'; - import { CallbackModel } from '../../services/models/Callback'; +import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions'; import { CallbacksList, CallbackTitle, CallbackView } from '../Callbacks'; import * as simpleCallbackFixture from './fixtures/simple-callback.json'; @@ -21,6 +20,7 @@ describe('Components', () => { { $ref: '#/components/callbacks/Test' }, options, ); + // There should be 1 operation defined in simple-callback.json, just get it manually for readability. const callbackViewElement = shallow( , ).getElement(); diff --git a/src/components/__tests__/fixtures/simple-callback.json b/src/components/__tests__/fixtures/simple-callback.json index 5ca4af74..6ee56361 100644 --- a/src/components/__tests__/fixtures/simple-callback.json +++ b/src/components/__tests__/fixtures/simple-callback.json @@ -1,64 +1,66 @@ { - "openapi": "3.0.0", - "info": { - "version": "1.0", - "title": "Foo" - }, - "components": { - "callbacks": { - "Test": { - "post": { - "operationId": "testCallback", - "description": "Test callback.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "title": "TestTitle", - "type": "object", - "description": "Test description", - "properties": { - "type": { - "type": "string", - "description": "The type of response.", - "enum": [ - "TestResponse.Complete" - ] - }, - "status": { - "type": "string", - "enum": [ - "FAILURE", - "SUCCESS" - ] - } - }, - "required": [ - "status" - ] - } - } - } - }, - "parameters": [ - { - "name": "X-Test-Header", - "in": "header", - "required": true, - "example": "1", - "description": "This is a test header parameter", + "openapi": "3.0.0", + "info": { + "version": "1.0", + "title": "Foo" + }, + "components": { + "callbacks": { + "Test": { + "/test": { + "post": { + "operationId": "testCallback", + "description": "Test callback.", + "requestBody": { + "content": { + "application/json": { "schema": { - "type": "string" + "title": "TestTitle", + "type": "object", + "description": "Test description", + "properties": { + "type": { + "type": "string", + "description": "The type of response.", + "enum": [ + "TestResponse.Complete" + ] + }, + "status": { + "type": "string", + "enum": [ + "FAILURE", + "SUCCESS" + ] + } + }, + "required": [ + "status" + ] } } - ], - "responses": { - "204": { - "description": "Test response." + } + }, + "parameters": [ + { + "name": "X-Test-Header", + "in": "header", + "required": true, + "example": "1", + "description": "This is a test header parameter", + "schema": { + "type": "string" } } + ], + "responses": { + "204": { + "description": "Test response." + } } } + } } } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/services/models/Callback.ts b/src/services/models/Callback.ts index 120f8edb..1a60ed3a 100644 --- a/src/services/models/Callback.ts +++ b/src/services/models/Callback.ts @@ -1,4 +1,5 @@ import { action, observable } from 'mobx'; + import { OpenAPICallback, Referenced } from '../../types'; import { isOperationName } from '../../utils'; import { OpenAPIParser } from '../OpenAPIParser';