mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-29 20:13:43 +03:00
fix: change look of additionalProperties
This commit is contained in:
parent
8376068bfa
commit
126c6a689a
|
@ -1,5 +1,5 @@
|
||||||
import { transparentize } from 'polished';
|
import { transparentize } from 'polished';
|
||||||
import styled from '../styled-components';
|
import styled, { withProps } from '../styled-components';
|
||||||
import { deprecatedCss } from './mixins';
|
import { deprecatedCss } from './mixins';
|
||||||
|
|
||||||
export const PropertiesTableCaption = styled.caption`
|
export const PropertiesTableCaption = styled.caption`
|
||||||
|
@ -57,7 +57,7 @@ export const PropertyCellWithInner = PropertyCell.extend`
|
||||||
padding: 0;
|
padding: 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const PropertyNameCell = PropertyCell.extend`
|
export const PropertyNameCell = withProps<{ kind?: string }>(PropertyCell.extend)`
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
@ -68,6 +68,8 @@ export const PropertyNameCell = PropertyCell.extend`
|
||||||
&.deprecated {
|
&.deprecated {
|
||||||
${deprecatedCss};
|
${deprecatedCss};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
${({ kind }) => (kind !== 'field' ? 'font-style: italic' : '')};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const PropertyDetailsCell = styled.td`
|
export const PropertyDetailsCell = styled.td`
|
||||||
|
|
|
@ -32,23 +32,29 @@ export class Field extends React.PureComponent<FieldProps> {
|
||||||
};
|
};
|
||||||
render() {
|
render() {
|
||||||
const { className, field, isLast } = this.props;
|
const { className, field, isLast } = this.props;
|
||||||
const { name, expanded, deprecated, required } = field;
|
const { name, expanded, deprecated, required, kind } = field;
|
||||||
const withSubSchema = !field.schema.isPrimitive && !field.schema.isCircular;
|
const withSubSchema = !field.schema.isPrimitive && !field.schema.isCircular;
|
||||||
|
|
||||||
const paramName = withSubSchema ? (
|
const paramName = withSubSchema ? (
|
||||||
<ClickablePropertyNameCell onClick={this.toggle} className={deprecated ? 'deprecated' : ''}>
|
<ClickablePropertyNameCell
|
||||||
|
onClick={this.toggle}
|
||||||
|
className={deprecated ? 'deprecated' : ''}
|
||||||
|
kind={kind}
|
||||||
|
title="Test"
|
||||||
|
>
|
||||||
<PropertyBullet />
|
<PropertyBullet />
|
||||||
{name}
|
{name}
|
||||||
<ShelfIcon size={'1.2em'} direction={expanded ? 'down' : 'right'} />
|
<ShelfIcon size={'1.2em'} direction={expanded ? 'down' : 'right'} />
|
||||||
{required && <RequiredLabel> required </RequiredLabel>}
|
{required && <RequiredLabel> required </RequiredLabel>}
|
||||||
</ClickablePropertyNameCell>
|
</ClickablePropertyNameCell>
|
||||||
) : (
|
) : (
|
||||||
<PropertyNameCell className={deprecated ? 'deprecated' : undefined}>
|
<PropertyNameCell className={deprecated ? 'deprecated' : undefined} kind={kind} title="oops">
|
||||||
<PropertyBullet />
|
<PropertyBullet />
|
||||||
{name}
|
{name}
|
||||||
{required && <RequiredLabel> required </RequiredLabel>}
|
{required && <RequiredLabel> required </RequiredLabel>}
|
||||||
</PropertyNameCell>
|
</PropertyNameCell>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<tr className={isLast ? 'last ' + className : className}>
|
<tr className={isLast ? 'last ' + className : className}>
|
||||||
|
|
|
@ -11,6 +11,7 @@ exports[`Components SchemaView discriminator should correctly render discriminat
|
||||||
"example": undefined,
|
"example": undefined,
|
||||||
"expanded": false,
|
"expanded": false,
|
||||||
"in": undefined,
|
"in": undefined,
|
||||||
|
"kind": "field",
|
||||||
"name": "packSize",
|
"name": "packSize",
|
||||||
"required": false,
|
"required": false,
|
||||||
"schema": SchemaModel {
|
"schema": SchemaModel {
|
||||||
|
@ -57,6 +58,7 @@ exports[`Components SchemaView discriminator should correctly render discriminat
|
||||||
"example": undefined,
|
"example": undefined,
|
||||||
"expanded": false,
|
"expanded": false,
|
||||||
"in": undefined,
|
"in": undefined,
|
||||||
|
"kind": "field",
|
||||||
"name": "type",
|
"name": "type",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": SchemaModel {
|
"schema": SchemaModel {
|
||||||
|
|
|
@ -19,14 +19,16 @@ export class FieldModel {
|
||||||
example?: string;
|
example?: string;
|
||||||
deprecated: boolean;
|
deprecated: boolean;
|
||||||
in?: string;
|
in?: string;
|
||||||
|
kind: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
parser: OpenAPIParser,
|
parser: OpenAPIParser,
|
||||||
infoOrRef: Referenced<OpenAPIParameter> & { name?: string },
|
infoOrRef: Referenced<OpenAPIParameter> & { name?: string; kind?: string },
|
||||||
pointer: string,
|
pointer: string,
|
||||||
options: RedocNormalizedOptions,
|
options: RedocNormalizedOptions,
|
||||||
) {
|
) {
|
||||||
const info = parser.deref<OpenAPIParameter>(infoOrRef);
|
const info = parser.deref<OpenAPIParameter>(infoOrRef);
|
||||||
|
this.kind = infoOrRef.kind || 'field';
|
||||||
this.name = infoOrRef.name || info.name;
|
this.name = infoOrRef.name || info.name;
|
||||||
this.in = info.in;
|
this.in = info.in;
|
||||||
this.required = !!info.required;
|
this.required = !!info.required;
|
||||||
|
|
|
@ -244,9 +244,10 @@ function buildFields(
|
||||||
new FieldModel(
|
new FieldModel(
|
||||||
parser,
|
parser,
|
||||||
{
|
{
|
||||||
name: '[property name] *',
|
name: 'property name *',
|
||||||
required: false,
|
required: false,
|
||||||
schema: additionalProps,
|
schema: additionalProps,
|
||||||
|
kind: 'additionalProperties',
|
||||||
},
|
},
|
||||||
$ref + '/additionalProperties',
|
$ref + '/additionalProperties',
|
||||||
options,
|
options,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user