Skip to content

Commit 126c6a6

Browse files
committed
fix: change look of additionalProperties
1 parent 8376068 commit 126c6a6

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

src/common-elements/fields-layout.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { transparentize } from 'polished';
2-
import styled from '../styled-components';
2+
import styled, { withProps } from '../styled-components';
33
import { deprecatedCss } from './mixins';
44

55
export const PropertiesTableCaption = styled.caption`
@@ -57,7 +57,7 @@ export const PropertyCellWithInner = PropertyCell.extend`
5757
padding: 0;
5858
`;
5959

60-
export const PropertyNameCell = PropertyCell.extend`
60+
export const PropertyNameCell = withProps<{ kind?: string }>(PropertyCell.extend)`
6161
vertical-align: top;
6262
line-height: 20px;
6363
white-space: nowrap;
@@ -68,6 +68,8 @@ export const PropertyNameCell = PropertyCell.extend`
6868
&.deprecated {
6969
${deprecatedCss};
7070
}
71+
72+
${({ kind }) => (kind !== 'field' ? 'font-style: italic' : '')};
7173
`;
7274

7375
export const PropertyDetailsCell = styled.td`

src/components/Fields/Field.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,29 @@ export class Field extends React.PureComponent<FieldProps> {
3232
};
3333
render() {
3434
const { className, field, isLast } = this.props;
35-
const { name, expanded, deprecated, required } = field;
35+
const { name, expanded, deprecated, required, kind } = field;
3636
const withSubSchema = !field.schema.isPrimitive && !field.schema.isCircular;
3737

3838
const paramName = withSubSchema ? (
39-
<ClickablePropertyNameCell onClick={this.toggle} className={deprecated ? 'deprecated' : ''}>
39+
<ClickablePropertyNameCell
40+
onClick={this.toggle}
41+
className={deprecated ? 'deprecated' : ''}
42+
kind={kind}
43+
title="Test"
44+
>
4045
<PropertyBullet />
4146
{name}
4247
<ShelfIcon size={'1.2em'} direction={expanded ? 'down' : 'right'} />
4348
{required && <RequiredLabel> required </RequiredLabel>}
4449
</ClickablePropertyNameCell>
4550
) : (
46-
<PropertyNameCell className={deprecated ? 'deprecated' : undefined}>
51+
<PropertyNameCell className={deprecated ? 'deprecated' : undefined} kind={kind} title="oops">
4752
<PropertyBullet />
4853
{name}
4954
{required && <RequiredLabel> required </RequiredLabel>}
5055
</PropertyNameCell>
5156
);
57+
5258
return (
5359
<>
5460
<tr className={isLast ? 'last ' + className : className}>

src/components/__tests__/__snapshots__/DiscriminatorDropdown.test.tsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports[`Components SchemaView discriminator should correctly render discriminat
1111
"example": undefined,
1212
"expanded": false,
1313
"in": undefined,
14+
"kind": "field",
1415
"name": "packSize",
1516
"required": false,
1617
"schema": SchemaModel {
@@ -57,6 +58,7 @@ exports[`Components SchemaView discriminator should correctly render discriminat
5758
"example": undefined,
5859
"expanded": false,
5960
"in": undefined,
61+
"kind": "field",
6062
"name": "type",
6163
"required": true,
6264
"schema": SchemaModel {

src/services/models/Field.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ export class FieldModel {
1919
example?: string;
2020
deprecated: boolean;
2121
in?: string;
22+
kind: string;
2223

2324
constructor(
2425
parser: OpenAPIParser,
25-
infoOrRef: Referenced<OpenAPIParameter> & { name?: string },
26+
infoOrRef: Referenced<OpenAPIParameter> & { name?: string; kind?: string },
2627
pointer: string,
2728
options: RedocNormalizedOptions,
2829
) {
2930
const info = parser.deref<OpenAPIParameter>(infoOrRef);
31+
this.kind = infoOrRef.kind || 'field';
3032
this.name = infoOrRef.name || info.name;
3133
this.in = info.in;
3234
this.required = !!info.required;

src/services/models/Schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ function buildFields(
244244
new FieldModel(
245245
parser,
246246
{
247-
name: '[property name] *',
247+
name: 'property name *',
248248
required: false,
249249
schema: additionalProps,
250+
kind: 'additionalProperties',
250251
},
251252
$ref + '/additionalProperties',
252253
options,

0 commit comments

Comments
 (0)