Skip to content

Commit

Permalink
fix: change look of additionalProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed May 14, 2018
1 parent 8376068 commit 126c6a6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/common-elements/fields-layout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { transparentize } from 'polished';
import styled from '../styled-components';
import styled, { withProps } from '../styled-components';
import { deprecatedCss } from './mixins';

export const PropertiesTableCaption = styled.caption`
Expand Down Expand Up @@ -57,7 +57,7 @@ export const PropertyCellWithInner = PropertyCell.extend`
padding: 0;
`;

export const PropertyNameCell = PropertyCell.extend`
export const PropertyNameCell = withProps<{ kind?: string }>(PropertyCell.extend)`
vertical-align: top;
line-height: 20px;
white-space: nowrap;
Expand All @@ -68,6 +68,8 @@ export const PropertyNameCell = PropertyCell.extend`
&.deprecated {
${deprecatedCss};
}
${({ kind }) => (kind !== 'field' ? 'font-style: italic' : '')};
`;

export const PropertyDetailsCell = styled.td`
Expand Down
12 changes: 9 additions & 3 deletions src/components/Fields/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,29 @@ export class Field extends React.PureComponent<FieldProps> {
};
render() {
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 paramName = withSubSchema ? (
<ClickablePropertyNameCell onClick={this.toggle} className={deprecated ? 'deprecated' : ''}>
<ClickablePropertyNameCell
onClick={this.toggle}
className={deprecated ? 'deprecated' : ''}
kind={kind}
title="Test"
>
<PropertyBullet />
{name}
<ShelfIcon size={'1.2em'} direction={expanded ? 'down' : 'right'} />
{required && <RequiredLabel> required </RequiredLabel>}
</ClickablePropertyNameCell>
) : (
<PropertyNameCell className={deprecated ? 'deprecated' : undefined}>
<PropertyNameCell className={deprecated ? 'deprecated' : undefined} kind={kind} title="oops">

This comment has been minimized.

Copy link
@donwitti

donwitti May 18, 2018

oops

This comment has been minimized.

Copy link
@donwitti

donwitti May 18, 2018

The same for L. 43 馃檪

This comment has been minimized.

Copy link
@RomanHotsiy

RomanHotsiy May 18, 2018

Author Member

oops 馃檲
Thanks! Fixed now.

This comment has been minimized.

Copy link
@donwitti

donwitti May 18, 2018

Thanks in return for the fast reaction 馃檪

<PropertyBullet />
{name}
{required && <RequiredLabel> required </RequiredLabel>}
</PropertyNameCell>
);

return (
<>
<tr className={isLast ? 'last ' + className : className}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ exports[`Components SchemaView discriminator should correctly render discriminat
"example": undefined,
"expanded": false,
"in": undefined,
"kind": "field",
"name": "packSize",
"required": false,
"schema": SchemaModel {
Expand Down Expand Up @@ -57,6 +58,7 @@ exports[`Components SchemaView discriminator should correctly render discriminat
"example": undefined,
"expanded": false,
"in": undefined,
"kind": "field",
"name": "type",
"required": true,
"schema": SchemaModel {
Expand Down
4 changes: 3 additions & 1 deletion src/services/models/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ export class FieldModel {
example?: string;
deprecated: boolean;
in?: string;
kind: string;

constructor(
parser: OpenAPIParser,
infoOrRef: Referenced<OpenAPIParameter> & { name?: string },
infoOrRef: Referenced<OpenAPIParameter> & { name?: string; kind?: string },
pointer: string,
options: RedocNormalizedOptions,
) {
const info = parser.deref<OpenAPIParameter>(infoOrRef);
this.kind = infoOrRef.kind || 'field';
this.name = infoOrRef.name || info.name;
this.in = info.in;
this.required = !!info.required;
Expand Down
3 changes: 2 additions & 1 deletion src/services/models/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,10 @@ function buildFields(
new FieldModel(
parser,
{
name: '[property name] *',
name: 'property name *',
required: false,
schema: additionalProps,
kind: 'additionalProperties',
},
$ref + '/additionalProperties',
options,
Expand Down

0 comments on commit 126c6a6

Please sign in to comment.