mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-08 06:04:56 +03:00
Show title and description on schemas, fix #598.
This commit is contained in:
parent
822d038190
commit
ec3b260056
|
@ -3,13 +3,6 @@
|
|||
import styled, { extensionsHook, withProps } from '../styled-components';
|
||||
import { deprecatedCss } from './mixins';
|
||||
|
||||
export const PropertiesTableCaption = styled.caption`
|
||||
text-align: right;
|
||||
font-size: 0.9em;
|
||||
font-weight: normal;
|
||||
color: ${props => props.theme.colors.text.secondary};
|
||||
`;
|
||||
|
||||
export const PropertyCell = styled.td`
|
||||
border-left: 1px solid ${props => props.theme.schema.linesColor};
|
||||
box-sizing: border-box;
|
||||
|
|
|
@ -74,7 +74,6 @@ export class Field extends React.Component<FieldProps> {
|
|||
schema={field.schema}
|
||||
skipReadOnly={this.props.skipReadOnly}
|
||||
skipWriteOnly={this.props.skipWriteOnly}
|
||||
showTitle={this.props.showTitle}
|
||||
/>
|
||||
</InnerPropertiesWrap>
|
||||
</PropertyCellWithInner>
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
import { observer } from 'mobx-react';
|
||||
import * as React from 'react';
|
||||
|
||||
import styled from '../../styled-components';
|
||||
|
||||
import { SchemaModel } from '../../services/models';
|
||||
|
||||
import { PropertiesTable, PropertiesTableCaption } from '../../common-elements/fields-layout';
|
||||
import { PropertiesTable } from '../../common-elements/fields-layout';
|
||||
import { H3 } from '../../common-elements/headers';
|
||||
|
||||
import { Field } from '../Fields/Field';
|
||||
import { Markdown } from '../Markdown/Markdown';
|
||||
import { DiscriminatorDropdown } from './DiscriminatorDropdown';
|
||||
import { SchemaProps } from './Schema';
|
||||
|
||||
|
@ -17,6 +22,18 @@ export interface ObjectSchemaProps extends SchemaProps {
|
|||
};
|
||||
}
|
||||
|
||||
export const ObjectSchemaDetails = styled.div`
|
||||
margin: 0 0 0.5em 0;
|
||||
`;
|
||||
|
||||
export const ObjectSchemaTitle = styled(H3)`
|
||||
margin: 0.5em 0 0 0;
|
||||
`;
|
||||
|
||||
export const ObjectSchemaDescription = styled.div`
|
||||
margin: 0.5em 0 0 0;
|
||||
`;
|
||||
|
||||
@observer
|
||||
export class ObjectSchema extends React.Component<ObjectSchemaProps> {
|
||||
get parentSchema() {
|
||||
|
@ -26,7 +43,6 @@ export class ObjectSchema extends React.Component<ObjectSchemaProps> {
|
|||
render() {
|
||||
const {
|
||||
schema: { fields = [] },
|
||||
showTitle,
|
||||
discriminator,
|
||||
} = this.props;
|
||||
|
||||
|
@ -42,8 +58,16 @@ export class ObjectSchema extends React.Component<ObjectSchemaProps> {
|
|||
: fields;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<ObjectSchemaDetails>
|
||||
<ObjectSchemaTitle>{this.props.schema.title}</ObjectSchemaTitle>
|
||||
|
||||
<ObjectSchemaDescription>
|
||||
<Markdown dense={true} source={this.props.schema.description} />
|
||||
</ObjectSchemaDescription>
|
||||
</ObjectSchemaDetails>
|
||||
|
||||
<PropertiesTable>
|
||||
{showTitle && <PropertiesTableCaption>{this.props.schema.title}</PropertiesTableCaption>}
|
||||
<tbody>
|
||||
{mapWithLast(filteredFields, (field, isLast) => {
|
||||
return (
|
||||
|
@ -66,12 +90,12 @@ export class ObjectSchema extends React.Component<ObjectSchemaProps> {
|
|||
showExamples={false}
|
||||
skipReadOnly={this.props.skipReadOnly}
|
||||
skipWriteOnly={this.props.skipWriteOnly}
|
||||
showTitle={this.props.showTitle}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</PropertiesTable>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import { ObjectSchema } from './ObjectSchema';
|
|||
import { OneOfSchema } from './OneOfSchema';
|
||||
|
||||
export interface SchemaOptions {
|
||||
showTitle?: boolean;
|
||||
skipReadOnly?: boolean;
|
||||
skipWriteOnly?: boolean;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Components SchemaView discriminator should correctly render discriminator dropdown 1`] = `
|
||||
<div>
|
||||
<styled.div>
|
||||
<Styled(styled.h2)>
|
||||
Dog
|
||||
</Styled(styled.h2)>
|
||||
<styled.div>
|
||||
<Markdown
|
||||
dense={true}
|
||||
source=""
|
||||
/>
|
||||
</styled.div>
|
||||
</styled.div>
|
||||
<styled.table>
|
||||
<tbody>
|
||||
<Field
|
||||
|
@ -102,4 +114,5 @@ exports[`Components SchemaView discriminator should correctly render discriminat
|
|||
/>
|
||||
</tbody>
|
||||
</styled.table>
|
||||
</div>
|
||||
`;
|
||||
|
|
Loading…
Reference in New Issue
Block a user