mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-07 13:30:33 +03:00
bundle and test
This commit is contained in:
parent
4359724434
commit
ffb70d2db2
|
@ -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,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user