bundle and test

This commit is contained in:
Dimitar Nanov 2018-10-19 20:04:35 +03:00 committed by Roman Hotsiy
parent 4359724434
commit ffb70d2db2
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
3 changed files with 37 additions and 32 deletions

View File

@ -1,10 +1,10 @@
import * as React from 'react'; import * as React from 'react';
import { Schema } from '../Schema'; import { Schema } from '../Schema';
import { MiddlePanel, Row, Section, DarkRightPanel } from '../../common-elements'; import { DarkRightPanel, MiddlePanel, Row, Section } from '../../common-elements';
import { OpenAPIParser, RedocNormalizedOptions, MediaTypeModel } from '../../services'; import { MediaTypeModel, OpenAPIParser, RedocNormalizedOptions } from '../../services';
import { MediaTypeSamples } from '../PayloadSamples/MediaTypeSamples';
import { OpenAPIMediaType } from '../../types'; import { OpenAPIMediaType } from '../../types';
import { MediaTypeSamples } from '../PayloadSamples/MediaTypeSamples';
export interface ObjectDescriptionProps { export interface ObjectDescriptionProps {
schemaRef: string; schemaRef: string;
@ -14,6 +14,37 @@ export interface ObjectDescriptionProps {
} }
export class ObjectDescription extends React.PureComponent<ObjectDescriptionProps> { export class ObjectDescription extends React.PureComponent<ObjectDescriptionProps> {
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; private mediaModel: MediaTypeModel;
constructor(props: ObjectDescriptionProps) { constructor(props: ObjectDescriptionProps) {
@ -35,30 +66,4 @@ export class ObjectDescription extends React.PureComponent<ObjectDescriptionProp
</Section> </Section>
); );
} }
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,
);
}
} }

View File

@ -13,8 +13,8 @@ import { SearchStore } from './SearchStore';
import { ObjectDescription } from '../components/ObjectDescription/ObjectDescription'; import { ObjectDescription } from '../components/ObjectDescription/ObjectDescription';
import { SecurityDefs } from '../components/SecuritySchemes/SecuritySchemes'; import { SecurityDefs } from '../components/SecuritySchemes/SecuritySchemes';
import { import {
SECURITY_DEFINITIONS_COMPONENT_NAME,
OBJECT_DEFINTION_COMPONENT_NAME, OBJECT_DEFINTION_COMPONENT_NAME,
SECURITY_DEFINITIONS_COMPONENT_NAME,
} from '../utils/openapi'; } from '../utils/openapi';
export interface StoreState { export interface StoreState {

View File

@ -59,7 +59,7 @@ export class MenuBuilder {
*/ */
static addMarkdownItems( static addMarkdownItems(
description: string, description: string,
parent: GroupModel | undefined, grandparent: GroupModel | undefined,
options: RedocNormalizedOptions, options: RedocNormalizedOptions,
): ContentItemModel[] { ): ContentItemModel[] {
const renderer = new MarkdownRenderer(options); const renderer = new MarkdownRenderer(options);
@ -83,7 +83,7 @@ export class MenuBuilder {
return group; return group;
}); });
return mapHeadingsDeep(parent, headings, 1); return mapHeadingsDeep(grandparent, headings, 1);
} }
/** /**