mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 21:54:53 +03:00
parent
1fdfd1353d
commit
13aa7133bc
|
@ -14,7 +14,7 @@ export class ConstraintsView extends React.PureComponent<ConstraintsViewProps> {
|
||||||
<span>
|
<span>
|
||||||
{' '}
|
{' '}
|
||||||
{this.props.constraints.map(constraint => (
|
{this.props.constraints.map(constraint => (
|
||||||
<ConstraintItem key={constraint}> {constraint} </ConstraintItem>
|
<ConstraintItem key={constraint}>{constraint}</ConstraintItem>
|
||||||
))}
|
))}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
|
@ -335,7 +335,8 @@ describe('Utils', () => {
|
||||||
min: number | undefined = undefined,
|
min: number | undefined = undefined,
|
||||||
max: number | undefined = undefined,
|
max: number | undefined = undefined,
|
||||||
multipleOf: number | undefined = undefined,
|
multipleOf: number | undefined = undefined,
|
||||||
) => ({ type: 'array', minItems: min, maxItems: max, multipleOf });
|
uniqueItems?: boolean,
|
||||||
|
) => ({ type: 'array', minItems: min, maxItems: max, multipleOf, uniqueItems });
|
||||||
|
|
||||||
it('should not have a humanized constraint without schema constraints', () => {
|
it('should not have a humanized constraint without schema constraints', () => {
|
||||||
expect(humanizeConstraints(itemConstraintSchema())).toHaveLength(0);
|
expect(humanizeConstraints(itemConstraintSchema())).toHaveLength(0);
|
||||||
|
@ -372,6 +373,12 @@ describe('Utils', () => {
|
||||||
'multiple of 0.5',
|
'multiple of 0.5',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should have a humanized constraint when uniqueItems is set', () => {
|
||||||
|
expect(humanizeConstraints(itemConstraintSchema(undefined, undefined, undefined, true))).toContain(
|
||||||
|
'unique',
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('OpenAPI pluralizeType', () => {
|
describe('OpenAPI pluralizeType', () => {
|
||||||
|
|
|
@ -448,6 +448,10 @@ export function humanizeConstraints(schema: OpenAPISchema): string[] {
|
||||||
res.push(numberRange);
|
res.push(numberRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (schema.uniqueItems) {
|
||||||
|
res.push('unique');
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user