From ffb70d2db2f5bb312da25adef5f347f52ca67c1b Mon Sep 17 00:00:00 2001 From: Dimitar Nanov Date: Fri, 19 Oct 2018 20:04:35 +0300 Subject: [PATCH] bundle and test --- .../ObjectDescription/ObjectDescription.tsx | 63 ++++++++++--------- src/services/AppStore.ts | 2 +- src/services/MenuBuilder.ts | 4 +- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/components/ObjectDescription/ObjectDescription.tsx b/src/components/ObjectDescription/ObjectDescription.tsx index 7a14b6de..12fe0a8d 100644 --- a/src/components/ObjectDescription/ObjectDescription.tsx +++ b/src/components/ObjectDescription/ObjectDescription.tsx @@ -1,10 +1,10 @@ import * as React from 'react'; import { Schema } from '../Schema'; -import { MiddlePanel, Row, Section, DarkRightPanel } from '../../common-elements'; -import { OpenAPIParser, RedocNormalizedOptions, MediaTypeModel } from '../../services'; -import { MediaTypeSamples } from '../PayloadSamples/MediaTypeSamples'; +import { DarkRightPanel, MiddlePanel, Row, Section } from '../../common-elements'; +import { MediaTypeModel, OpenAPIParser, RedocNormalizedOptions } from '../../services'; import { OpenAPIMediaType } from '../../types'; +import { MediaTypeSamples } from '../PayloadSamples/MediaTypeSamples'; export interface ObjectDescriptionProps { schemaRef: string; @@ -14,6 +14,37 @@ export interface ObjectDescriptionProps { } export class ObjectDescription extends React.PureComponent { + private static getMediaType(schemaRef, examplesRef): OpenAPIMediaType { + if (!schemaRef) { + return {}; + } + + const info: OpenAPIMediaType = { + schema: { $ref: schemaRef }, + }; + + if (examplesRef) { + info.examples = { object: { $ref: examplesRef } }; + } + + return info; + } + + private static getMediaModel({ + schemaRef, + examplesRef, + parser, + options, + }: ObjectDescriptionProps) { + return new MediaTypeModel( + parser, + 'json', + false, + ObjectDescription.getMediaType(schemaRef, examplesRef), + options, + ); + } + private mediaModel: MediaTypeModel; constructor(props: ObjectDescriptionProps) { @@ -35,30 +66,4 @@ export class ObjectDescription extends React.PureComponent ); } - - private static getMediaType(schemaRef, examplesRef): OpenAPIMediaType { - if (!schemaRef) return {}; - - const info: OpenAPIMediaType = { - schema: { $ref: schemaRef }, - }; - - if (examplesRef) info.examples = { object: { $ref: examplesRef } }; - return info; - } - - private static getMediaModel({ - schemaRef, - examplesRef, - parser, - options, - }: ObjectDescriptionProps) { - return new MediaTypeModel( - parser, - 'json', - false, - ObjectDescription.getMediaType(schemaRef, examplesRef), - options, - ); - } } diff --git a/src/services/AppStore.ts b/src/services/AppStore.ts index 2f004454..d4044af5 100644 --- a/src/services/AppStore.ts +++ b/src/services/AppStore.ts @@ -13,8 +13,8 @@ import { SearchStore } from './SearchStore'; import { ObjectDescription } from '../components/ObjectDescription/ObjectDescription'; import { SecurityDefs } from '../components/SecuritySchemes/SecuritySchemes'; import { - SECURITY_DEFINITIONS_COMPONENT_NAME, OBJECT_DEFINTION_COMPONENT_NAME, + SECURITY_DEFINITIONS_COMPONENT_NAME, } from '../utils/openapi'; export interface StoreState { diff --git a/src/services/MenuBuilder.ts b/src/services/MenuBuilder.ts index 99543f92..6c17e51a 100644 --- a/src/services/MenuBuilder.ts +++ b/src/services/MenuBuilder.ts @@ -59,7 +59,7 @@ export class MenuBuilder { */ static addMarkdownItems( description: string, - parent: GroupModel | undefined, + grandparent: GroupModel | undefined, options: RedocNormalizedOptions, ): ContentItemModel[] { const renderer = new MarkdownRenderer(options); @@ -83,7 +83,7 @@ export class MenuBuilder { return group; }); - return mapHeadingsDeep(parent, headings, 1); + return mapHeadingsDeep(grandparent, headings, 1); } /**